Answer by user4686 for Summation of a list of numbers
Here is a version which will print the sum exactly with the number of necessary digits. Hmm... that was not what was asked.Sorry.Ok, so I update the code to do the printing of partial sums which was...
View ArticleAnswer by egreg for Summation of a list of numbers
With expl3:\documentclass{article}\usepackage{xparse}\ExplSyntaxOn\NewDocumentCommand\sumlist{ m } { \tarass_sum_list:n { #1 } }\fp_new:N \l__tarass_partial_sum_fp\cs_new_protected:Npn...
View ArticleAnswer by remjg for Summation of a list of numbers
It seems like the definition of the macro \Sum is local to the group. At the next iteration, its content is forgotten and only the first global definition with \xdef is kept. I don't know much about it...
View ArticleSummation of a list of numbers
The next code gives : 1 1.2 3But 1 2.2 5.2 is expected. What is wrong ?\documentclass[tikz]{standalone}\begin{document}\xdef\Sum{0}\foreach \i in {1,1.2,3} { \pgfmathsetmacro\Sum{\Sum+\i} \Sum\...
View ArticleAnswer by AlexG for Summation of a list of numbers
Tikz groups the loop body of \foreach, making macro definitions local. Package pgfplots provides a non-grouping...
View ArticleAnswer by Black Mild for Summation of a list of numbers
Just practice with Asymptote using a built-in sum(a) function to calculate the sum of all elements of a given array of real number a.real[] a={1,1.2,-5};write(a);real T=sum(a);write("The sum of all...
View Article
More Pages to Explore .....