Question: fsolve within loop returns unevaluated

I am new to Maple will appreciate any advice.

I am trying to write a procedure to solve a cubic equation using fsolve, print the root at each stage, and store results in a table for later use.  

I have restricted the range of fsolve, but I know from other sources that there is a solution within this range.

The instructions work if entered manually line by line, but not as a procedure.

The code is copied below.  Thanks for any suggestions.

Stephen Martin

Reg_IV := proc (beta, n) local alpha, b, c, d, k, `αL`, 

   `αR`, delta, eqn, x; `αL` := 3+beta-6*beta^(1/2);\

   `αR` := 1-beta; delta := (`αR`-`αL`)/n; 

   print(`β = `, evalf(beta, 5), `n = `, evalf(n, 5)); 

   print(`αL = `, evalf(`αL`, 5), ` αR = `, 

   evalf(`αR`, 5), `δ = `, evalf(delta, 5)); 

   print(``); for k from 0 to n+1 do alpha := `αL`+k*delta\

  ; b := -5+alpha-3*beta; c := 8-4*alpha-6*beta+2*beta^2-2*alpha\

  *beta; d := -(4*beta+4)*(1-alpha-beta); eqn := proc (b, c, d, 

   x) options operator, arrow; {x^3+b*x^2+c*x+d} end proc; x[k] 

   := fsolve(eqn, 0 .. 2); print(evalf(x[k], 5)) end do; 

   print(``); print(evalf(x, 5)) end proc


Reg_IV(0.2, 4);
                    β = , 0.2, n = , 4.

 αL = , 0.51672,  αR = , 0.8, δ = , 0.070820


                      fsolve(eqn, 0 .. 2)

                      fsolve(eqn, 0 .. 2)

                      fsolve(eqn, 0 .. 2)

                      fsolve(eqn, 0 .. 2)

                      fsolve(eqn, 0 .. 2)

                      fsolve(eqn, 0 .. 2)


   TABLE([0 = fsolve(eqn, 0 .. 2), 1 = fsolve(eqn, 0 .. 2), 

     2 = fsolve(eqn, 0 .. 2), 3 = fsolve(eqn, 0 .. 2), 

     4 = fsolve(eqn, 0 .. 2), 5 = fsolve(eqn, 0 .. 2)])


 

Please Wait...