Secant 2
Secant 2
Secant-2*)
Print["f(x): ", f[x], ", x0 : ", x0 , " x1 : ", x1 , " and iterations: ", k];
Plot[f[x], {x, x0 , x1 }]
For [i = 1, i ≤ k, i ++,
xi+1 = (xi-1 f[xi ] - xi f[xi-1 ]) / (f[xi ] - f[xi-1 ]);
Print["Iteration number: ", i, " Approximate Root= ", N[x i+1 ]];
If[Abs[f[xi+1 - xi ]] < ϵ, Break[]]
]
f(x): x2 Cos[x] + Sin[x], x0 : 1 x1 : 3 and iterations: 10
Out[23]=
2
-2
-4
-6
-8
$Aborted