Subhan331

Mr. SUBHAN ULLAH

20 Reputation

5 Badges

6 years, 245 days

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by Subhan331


I need a general coding in which we can change function and number of iteration at any time 

``

tol := 0.1e-5; n := 10; x := Array(0 .. n); x[0] := .1; f := proc (x) options operator, arrow; x^2-3 end proc; h := proc (x) options operator, arrow; unapply(diff(f(x), x), x) end proc; for k to n do x[k] := evalf(x[k-1]-f(x[k-1])/h(x[k-1])); if abs(x[k]-x[k-1]) < tol then print("Number of iterations" = k); print("approximate solution" = x[k]); print(f(x[k])); break end if; x[k-1] := x[k] end do; interface(rtablesize = n+1); x(); interface(rtablesize = n); plot([f(p), f(x[k-1])+(p-x[k-1])*h(x[k-1])], p = -1 .. 3, colour = [red, black])

0.1e-5

 

10

 

.1

 

proc (x) options operator, arrow; x^2-3 end proc

 

proc (x) options operator, arrow; unapply(diff(f(x), x), x) end proc

 

Error, (in h) invalid input: diff received .1, which is not valid for its 2nd argument

 

10

 

Array(0 .. 10, {0 = .1}, datatype = anything, storage = rectangular, order = Fortran_order)

 

11

 

Error, (in h) invalid input: diff received .1, which is not valid for its 2nd argument

 

``

``


 

Download err0r.mw

@tomleslie 

@tomleslie why dont it shows values for each iteration?

@tomleslie Thanks alot God Bless You

1 2 Page 2 of 2