ModSim: Added result table to 2.5

parent 5c46eed8
...@@ -22,8 +22,8 @@ double f2(double x) { ...@@ -22,8 +22,8 @@ double f2(double x) {
#define PRINT_INTEGRAL(func, a, b, method, real) { \ #define PRINT_INTEGRAL(func, a, b, method, real) { \
_i = integral(&func, &method, a, b, atoi(argv[1])); \ _i = integral(&func, &method, a, b, atoi(argv[1])); \
printf(#func " from " #a " to " #b " using %-19s %.80e (%.2f%%)\n", \ printf(#func " from " #a " to " #b " using %-19s %.12e (%.12e)\n", \
#method " method:", _i, fabs((real - _i) / real * 100)); \ #method " method:", _i, fabs((real - _i))); \
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
......
\documentclass[10pt,a4paper]{article} \documentclass[10pt,a4paper]{article}
\usepackage{float,url,graphicx} \usepackage{float,url,graphicx,booktabs}
\usepackage[dutch]{babel} \usepackage[dutch]{babel}
...@@ -147,32 +147,37 @@ double sin(x); ...@@ -147,32 +147,37 @@ double sin(x);
\noindent Dit heeft het volgende resultaat gegeven als we het programma met \noindent Dit heeft het volgende resultaat gegeven als we het programma met
1.000.000 steps uitvoeren: 1.000.000 steps uitvoeren:
\begin{verbatim} \begin{table}[H]
f1 from 0 to 1 using rectangle method: 6.32120558829e-01 \begin{tabular}{llllrr} \toprule
f1 from 0 to 1 using trapezoidal method: 6.32120558829e-01 f & a & b & methode & \multicolumn{1}{l}{benadering} & \multicolumn{1}{l}{afwijking} \\
f1 from 0 to 1 using simpson method: 6.32120558829e-01 \midrule
f1 from 0 to 1 using gauss method: 6.32120558829e-01 f1 & 0 & 1 & rectangle & $ 6.321205588285 \cdot 10^{-01}$ & $3.952393967666 \cdot 10^{-14}$ \\
f1 & 0 & 1 & trapezoidal & $ 6.321205588286 \cdot 10^{-01}$ & $4.141131881852 \cdot 10^{-14}$ \\
f2 from 0 to 2 using rectangle method: 5.93994150290e-01 f1 & 0 & 1 & simpson & $ 6.321205588285 \cdot 10^{-01}$ & $1.276756478319 \cdot 10^{-14}$ \\
f2 from 0 to 2 using trapezoidal method: 5.93994150290e-01 f1 & 0 & 1 & gauss & $ 6.321205588285 \cdot 10^{-01}$ & $1.276756478319 \cdot 10^{-14}$ \\
f2 from 0 to 2 using simpson method: 5.93994150290e-01 \midrule
f2 from 0 to 2 using gauss method: 5.93994150290e-01 f2 & 0 & 2 & rectangle & $ 5.939941502904 \cdot 10^{-01}$ & $2.019495681793 \cdot 10^{-13}$ \\
f2 & 0 & 2 & trapezoidal & $ 5.939941502898 \cdot 10^{-01}$ & $3.644862189844 \cdot 10^{-13}$ \\
f2 from 0 to 20 using rectangle method: 9.99999956716e-01 f2 & 0 & 2 & simpson & $ 5.939941502902 \cdot 10^{-01}$ & $1.454392162259 \cdot 10^{-14}$ \\
f2 from 0 to 20 using trapezoidal method: 9.99999956715e-01 f2 & 0 & 2 & gauss & $ 5.939941502902 \cdot 10^{-01}$ & $1.454392162259 \cdot 10^{-14}$ \\
f2 from 0 to 20 using simpson method: 9.99999956716e-01 \midrule
f2 from 0 to 20 using gauss method: 9.99999956716e-01 f2 & 0 & 20 & rectangle & $ 9.999999567325 \cdot 10^{-01}$ & $1.671296434580 \cdot 10^{-11}$ \\
f2 & 0 & 20 & trapezoidal & $ 9.999999566825 \cdot 10^{-01}$ & $3.332367715103 \cdot 10^{-11}$ \\
f2 from 0 to 200 using rectangle method: 1.00000000001e+00 f2 & 0 & 20 & simpson & $ 9.999999567158 \cdot 10^{-01}$ & $2.831068712794 \cdot 10^{-14}$ \\
f2 from 0 to 200 using trapezoidal method: 9.99999999965e-01 f2 & 0 & 20 & gauss & $ 9.999999567158 \cdot 10^{-01}$ & $2.808864252302 \cdot 10^{-14}$ \\
f2 from 0 to 200 using simpson method: 9.99999999998e-01 \midrule
f2 from 0 to 200 using gauss method: 9.99999999998e-01 f2 & 0 & 200 & rectangle & $ 1.000000001666 \cdot 10^{+00}$ & $1.666276006063 \cdot 10^{-09}$ \\
f2 & 0 & 200 & trapezoidal & $ 9.999999966665 \cdot 10^{-01}$ & $3.333514797532 \cdot 10^{-09}$ \\
sin from 0 to 8 * M_PI using rectangle method: -1.04730878509e-13 f2 & 0 & 200 & simpson & $ 9.999999999998 \cdot 10^{-01}$ & $1.918465386552 \cdot 10^{-13}$ \\
sin from 0 to 8 * M_PI using trapezoidal method: -1.08168370335e-13 f2 & 0 & 200 & gauss & $ 9.999999999998 \cdot 10^{-01}$ & $1.918465386552 \cdot 10^{-13}$ \\
sin from 0 to 8 * M_PI using simpson method: -8.63149135973e-14 \midrule
sin from 0 to 8 * M_PI using gauss method: -8.55165510887e-14 sin & 0 & $8\pi$ & rectangle & $ 1.649022273643 \cdot 10^{-14}$ & $1.649022273643 \cdot 10^{-14}$ \\
\end{verbatim} sin & 0 & $8\pi$ & trapezoidal & $-2.597858752022 \cdot 10^{-14}$ & $2.597858752022 \cdot 10^{-14}$ \\
sin & 0 & $8\pi$ & simpson & $-1.797341770030 \cdot 10^{-14}$ & $1.797341770030 \cdot 10^{-14}$ \\
sin & 0 & $8\pi$ & gauss & $-1.797258919631 \cdot 10^{-14}$ & $1.797258919631 \cdot 10^{-14}$ \\
\bottomrule
\end{tabular}
\end{table}
% }}} % }}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment