## 15 Reputation

6 years, 169 days

## Help with my for loop...

Maple

Hello, I'm new here, I hope there is someone willing to give me a hand with my problem. I've been trying to solve a problem with a for loop and I have errors in my code, could you please tell me what's wrong with the  bold part?

restart;

with(plots);

g := proc (F, A, B, X0, g::evaln) local f, a, b, E, x0, erreur, N, n, x1, ps, pp, pic; f := F; a := A; b := B; x0 := X0; E :=

evalf(abs(f(x0)));

erreur := 0.1e-3;

N := 100;

n := 0;

for i to N do x1 := evalf(x0-f(x0)/(D(f))(x0));

E := abs(f(x1));

n := n+1; ps[n] := plot([[x0, 0.], [x0, f(x0)], [x1, 0.]], color = green, thickness = 2);

x0 := x1 end do; g := evalf(x1); pp := plot(f(x), x = a .. b, color = red); pic := seq(ps[i], i = 1 .. n); display(pp, pic) end proc;
Warning, `i` is implicitly declared local to procedure `g`
f := proc (x) options operator, arrow; sin(x)-cos(2*x)+.2 end proc;
x -> sin(x) - cos(2 x) + 0.2
a := 0; b := 6;

Thank you very much!

 Page 1 of 1
﻿