Forgot password?
 Create new account
View 136|Reply 0

tikz求和

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-5-16 00:14:29 |Read mode
In:=
     Sum[(i - 0.5)^2, {i, 0, 1, 0.2}]
Out:=
     0.7

在tikz中,
  1. \documentclass[tikz]{standalone}
  2. \begin{document}
  3. \begin{tikzpicture}
  4. \def\err{0}
  5. \newcounter{i};
  6. \loop
  7. \pgfmathsetmacro{\err}{\err+(0.1*\value{i}-0.5)^2}
  8. \ifnum \value{i}<9
  9. \addtocounter{i}{2};
  10. \repeat
  11. \node at(0,0){\err};
  12. \end{tikzpicture}
  13. \end{document}
Copy the Code

输出0.70006

手机版Mobile version|Leisure Math Forum

2025-4-20 22:07 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list