> #L=target length, t0=angle for the tip of the arrow > iter :=proc(t) > global l; local x0,y0,x,y,X,Y; > x0:=a*cos(t0);y0:=b*sin(t0); > x:=a*cos(t); y:=b*sin(t); > l:=sqrt((x-x0)^2+(y-y0)^2); > X:=x0+(x-x0)*L/l; Y:=y0+(y-y0)*L/l; > RETURN(arctan((Y/b),(X/a))); > end; > iter := proc(t) local x0, y0, x, y, X, Y; global l; x0 := a*cos(t0); y0 := b*sin(t0); x := a*cos(t); y := b*sin(t); l := sqrt((x - x0)^2 + (y - y0)^2); X := x0 + ((x - x0)*L)/l; Y := y0 + ((y - y0)*L)/l; RETURN(arctan(Y/b, X/a)) end > iter := proc (t) local x0, y0, x, y, X, Y; global l; x0 := a*cos(t0); y0 := b*sin(t0); x := a*cos(t); y := b*sin(t); l := sqrt((x-x0)^2+(y-y0)^2); X := x0+(x-x0)*L/l; Y := y0+(y-y0)*L/l; RETURN(arctan(Y/b,X/a)) end; iter := proc(t) local x0, y0, x, y, X, Y; global l; x0 := a*cos(t0); y0 := b*sin(t0); x := a*cos(t); y := b*sin(t); l := sqrt((x - x0)^2 + (y - y0)^2); X := x0 + ((x - x0)*L)/l; Y := y0 + ((y - y0)*L)/l; RETURN(arctan(Y/b, X/a)) end > a:=3; b:=0.5; L:=0.1;t0:=0;# small value of L: fast convergence... a := 3 b := .5 L := .1 t0 := 0 > #initialisation of angle > t:=t0+L/sqrt((a*sin(t0))^2+(b*cos(t0)^2)); > if (t > evalf(Pi/2)) then t:= evalf(Pi/2); fi; t := .1414213562 > #iteration > for i from 1 to 30 do t:=iter(t): print(i,l,l-L); if abs(l-L)<1e-5 then break; fi; od: 1, .07657519119, -.02342480881 2, .1048283676, .0048283676 3, .09900886367, -.00099113633 4, .1002041853, .0002041853 5, .09995796284, -.00004203716 -5 6, .1000086554, .86554 10 > a:=3; b:=0.5; L:=0.5;t0:=0;#larger value of L, slow convergence... a := 3 b := .5 L := .5 t0 := 0 > #initialisation of angle > t:=t0+L/sqrt((a*sin(t0))^2+(b*cos(t0)^2)); > if (t > evalf(Pi/2)) then t:= evalf(Pi/2); fi; t := .7071067812 > #iteration > for i from 1 to 30 do t:=iter(t): print(i,l,l-L); if abs(l-L)<1e-5 then break; fi; od: 1, .7892090456, .2892090456 2, .3718449450, -.1281550550 3, .5888779655, .0888779655 4, .4523038305, -.0476961695 5, .5298679218, .0298679218 6, .4829125443, -.0170874557 7, .5103161893, .0103161893 8, .4939663391, -.0060336609 9, .5035959667, .0035959667 10, .4978805683, -.0021194317 11, .5012574327, .0012574327 12, .4992568831, -.0007431169 13, .5004401811, .0004401811 14, .4997396175, -.0002603825 15, .5001541498, .0001541498 16, .4999087853, -.0000912147 17, .5000539895, .0000539895 18, .4999680494, -.0000319506 19, .5000189104, .0000189104 20, .4999888084, -.0000111916 -5 21, .5000066236, .66236 10 >