Program for Bhaskara:
The error message i am getting is: Error, (in Brounker) cannot determine if this expression is true or false: abs(a[200]/b[200]-5^(1/2)) < tol
isn't this the math forum :D
Brounker:=proc(n,m,tol) local a,b,i; a[1]:=1; b[1]:=1; for i from 1 to m-1 do a[i+1]:=a[i]+b[i]*n; b[i+1]:=a[i]+b[i]; if abs(a[m]/b[m]-sqrt(n))<tol then return a[m]/b[m]; end if; end do; return "Bb FAIL" end proc;
its the tolerence (tol)limit i am getting trouble with
huh? isn't this conway problem?
na, this is a different one
what is your algorithm? i can't read that ...
for i from 1 to m-1 do a[i+1]:=a[i]+b[i]*n; b[i+1]:=a[i]+b[i];
its suppose to give an approximation of sqrt(n)
Man ... i always use Newton's Rhapson's method for approximating ... can you give me some link
hold on
you know what i think the problem might just be asking me to output the error, meaing the abs value of the final iterate -the sqrt(n) I think i got it, sorry was wasting your time
do you necessarily need to use recursion?
try this squareroot := proc (Q, n) option remember; description `What the hell`; if n = 1 then return (1+Q)/(1+1) else return (squareroot(Q, n-1)+Q)/(squareroot(Q, n-1)+1) end if end proc squareroot(2, 12)
squareroot := proc (Q, n) option remember; description `I don't understand coding in Maple`; if n = 1 then return 1/2+(1/2)*Q else return (squareroot(Q, n-1)+Q)/(squareroot(Q, n-1)+1) end if end proc
Join our real-time social learning platform and learn together with your friends!