Hello, for an assignment I was given the task of iteratively calculating the water depth of a flow using Newton's method. For this I tried to create a procedure wich uses a number of input values. The code is listed below;
Newton := proc (n, y0, Q, b, m, k, S0) local A, P, Sf, y, F, dAdy, dPdy, Fdiff, i; global ylist; y := y0; for i from 0 to n do A[i] := (b+m*y[i])*y[i]; P[i] := b+2*y[i]*sqrt(1+m^2); Sf[i] := Q*abs(Q)*P[i]^(4/3)/(k^2*A[i]^(10/3)); F[i] := S0/Sf[i]-1; dAdy[i] := b+2*m*y; dPdy[i] := 2*sqrt(1+m^2); Fdiff := (2/3)*(F[i]-1)(5*dAdy[i]/A[i]-2*dPdy[i]/P[i]); y[i] := procname(evalf(y[i]-F[i](y[i])/Fdiff[i](y[i]))) end do; ylist := [seq(y[i], i = 0 .. n)]; return ylist end proc;
Newton(10, 1, 5, 12, 1, 30, 0.1e-4);
Error, (in Newton) invalid input: Newton uses a 2nd argument, y0, which is missing
As you can see, I get an error referring to the second argument y0, which is the starting value of the calculation. The error says the argument is missing, however it is right there in the brackets of the Newton procedure (along with the values of all other parameters). I have tried explicitly stating that y0:=1, and changing the name of the parameter, however that didn't help.
Am I missing something really simple, or is there something wrong with my code?
Thanks in advance.