1

I have the following code:

\documentclass[tikz,border=5]{article}
\usepackage{tikz}
\usepackage{xfp}
\usepackage{amsmath}
\usetikzlibrary{math}
\usepackage{fp}


\begin{document}

\tikzmath{
real \x; int \i; real \s;
    \s = 0;
    for \i in {1,2,...,15}{
        \s = \s + 2^\i; 
        \x{\i} = \s;
    };
}

\vspace{3cm}

\foreach \i in {1,2,...,15}{
O valor da soma \i~ é desta sequência é \x{\i} \\ 
}

\end{document}

Why tikzmath does not perform the calculations above of 2^14? How can I overcome this please? Any package, library to do calculation with bigger numbers?

1

1 Answer 1

1

The sagetex package gives you access to the Python programming language and a computer algebra system known as Sage. This lets you handle most any problem easily. Search this site for other examples.

\documentclass[12pt]{article}
\usepackage{sagetex}
\usepackage{amsmath}
\begin{document}
\begin{sagesilent}
output = r""
sum = 0
for i in range(1,37):
  sum += 2^i
  output += r"\noindent O valor da soma $%d$ é desta sequência é $%d$\\"%(i,sum)
\end{sagesilent}
\sagestr{output}
\end{document}

The output running in Cocalc is: enter image description here

The %d is for integer data, %f is for float and %s for string data.

Sage is not part of the LaTeX distribution. It can be downloaded onto your computer but the simplest way to get started is a free Cocalc account.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .