f = inline('3*cos(4*x) + 14*cos(2*x).*sin(x) - 15*cos(2*x) - 11*sin(x) + 11') f = Inline function: f(x) = 3*cos(4*x) + 14*cos(2*x).*sin(x) - 15*cos(2*x) - 11*sin(x) + 11 g = inline('-12*sin(4*x) + 14*(-2*sin(2*x).*sin(x)+cos(2*x).*cos(x))+30*sin(2*x)-11*cos(x)') g = Inline function: g(x) = -12*sin(4*x) + 14*(-2*sin(2*x).*sin(x)+cos(2*x).*cos(x))+30*sin(2*x)-11*cos(x) newton(f, g, -0.5, 0.0000000001, 0.5) r = -0.33983690945412 ans = | x_i | g(x_i) | error | error ratio | ans = -0.50000000000000 -0.38499267963579 0.16016309054588 0 -0.38499267963579 -0.34519615006708 0.04515577018166 0.28193618159941 -0.34519615006708 -0.33992694933625 0.00535924061296 0.11868340616054 -0.33992694933625 -0.33983693552615 0.00009003988213 0.01680086576319 -0.33983693552615 -0.33983690945412 0.00000002607203 0.00028956085939 -0.33983690945412 -0.33983690945412 0.00000000000000 0.00000009368243 -0.33983690945412 -0.33983690945412 0.00000000000000 0.11363636363636 newton(f, g, 0.5, 0.0000000001, 0.5) r = 0.52359630078870 ans = | x_i | g(x_i) | error | error ratio | Warning: Divide by zero. > In fpi_err at 10 In newton at 13 ans = 0.50000000000000 0.50788132816905 0.02359630078870 0 0.50788132816905 0.51312651126278 0.01571497261964 0.66599306223336 0.51312651126278 0.51661975397137 0.01046978952591 0.66623021110634 0.51661975397137 0.51894714334656 0.00697654681733 0.66635024515628 0.51894714334656 0.52049813681164 0.00464915744213 0.66639808545208 0.52049813681164 0.52153187784706 0.00309816397705 0.66639257018370 0.52153187784706 0.52222092886745 0.00206442294164 0.66633753310988 0.52222092886745 0.52268024851408 0.00137537192125 0.66622584621954 0.52268024851408 0.52298644064974 0.00091605227461 0.66603968022104 0.52298644064974 0.52319055953961 0.00060986013895 0.66574818474416 0.52319055953961 0.52332663450846 0.00040574124908 0.66530212939707 0.52332663450846 0.52341735020372 0.00026966628023 0.66462623862714 0.52341735020372 0.52347782611110 0.00017895058498 0.66360015357257 0.52347782611110 0.52351814345040 0.00011847467760 0.66205247451647 0.52351814345040 0.52354502354606 0.00007815733829 0.65969656871308 0.52354502354606 0.52356294530766 0.00005127724264 0.65607713566020 0.52356294530766 0.52357487500129 0.00003335548103 0.65049287595277 0.52357487500129 0.52358285443287 0.00002142578741 0.64234682700063 0.52358285443287 0.52358824904516 0.00001344635583 0.62757814086887 0.52358824904516 0.52359153987740 0.00000805174353 0.59880488346504 0.52359153987740 0.52359328110033 0.00000476091130 0.59128948639768 0.52359328110033 0.52359630078870 0.00000301968837 0.63426688268604 0.52359630078870 0.52359630078870 0 0 0.52359630078870 0.52359630078870 0 NaN exit