0
$\begingroup$

I'm newbie here, and using Mathematica for two weeks, so, anyone can help me with this? I tried using the Findroot command but I don't get it. Thanks in advance guys.

enter image description here

$\endgroup$
1
5
$\begingroup$
f[x_] := BesselJ[0, x]

Plot[f[x], {x, 0, 15},
 Epilog -> {Red, AbsolutePointSize[4],
   Tooltip[Point[{BesselJZero[0, #], 0}], BesselJZero[0, #] // N] & /@
    Range[5]}]

enter image description here

To see the progressive estimates using Newton-Raphson, use FixedPointList

(sol1a = Table[
    FixedPointList[# - f[#]/f'[#] &, x0], {x0, 3., 15, 3}]) // Column

enter image description here

To see just the final values use FixedPoint

(sol1b = Table[FixedPoint[# - f[#]/f'[#] &, x0], {x0, 3., 15, 3}])

(* {2.40483, 5.52008, 8.65373, 11.7915, 14.9309} *)

Alternatively, using NestList or Nest

(sol2a = Table[
    NestList[# - f[#]/f'[#] &, x0, 10], {x0, 3., 15., 3.}]) // Column

enter image description here

(sol2b = Table[Nest[# - f[#]/f'[#] &, x0, 10], {x0, 3., 15., 3.}])

(* {2.40483, 5.52008, 8.65373, 11.7915, 14.9309} *)

Using FindRoot

sol3 = x /. FindRoot[BesselJ[0, x] == 0, {x, #}] & /@ Range[3., 15, 3]

(* {2.40483, 5.52008, 8.65373, 11.7915, 14.9309} *)

Using NSolve

sol4 = x /. NSolve[{BesselJ[0, x] == 0, 0 < x < 15}, x]

(* {2.40483, 5.52008, 8.65373, 11.7915, 14.9309} *)

Solve or Reduce give the solution in terms of BesselJZero

x /. Solve[{BesselJ[0, x] == 0, 0 < x < 15}, x]

(* {BesselJZero[0, 1], BesselJZero[0, 2], BesselJZero[0, 3], BesselJZero[0, 4], 
 BesselJZero[0, 5]} *)

x /. {ToRules[Reduce[{BesselJ[0, x] == 0, 0 < x < 15}, x]]}

(* {BesselJZero[0, 1], BesselJZero[0, 2], BesselJZero[0, 3], BesselJZero[0, 4], 
 BesselJZero[0, 5]} *)

Comparing with the BesselJZero values

bjz = BesselJZero[0, #] & /@ Range[5];

sol1a[[All, -1]] == sol1b == sol2a[[All, -1]] == sol2b == sol3 == sol4 == bjz

(* True *)
$\endgroup$
3
  • $\begingroup$ thanks for the answer, but I do not have a formula, that's what I do not understand, how do I apply it? $\endgroup$
    – shatman
    Aug 20 '18 at 13:10
  • $\begingroup$ You gave Newton-Raphson formula, i.e., x[i+1] == x[i] - f[x[i]]/f'[x[i]]. When written as a pure function the RHS is # - f[#]/f'[#] &. FixedPointList and FixedPoint iterate this pure function until the results converge and stops automatically. NestList and Nest iterates the pure function a specified number of times. For a sufficiently large number of specified iterations the result will converge to the fixed point. In all of these cases a starting value (x[0]) must be specified that is in the region of the desired root. $\endgroup$
    – Bob Hanlon
    Aug 20 '18 at 14:35
  • $\begingroup$ thanks Bob, Now I understand it all $\endgroup$
    – shatman
    Aug 20 '18 at 19:41
0
$\begingroup$
  f[x_] := BesselJ[0, x]    
    x[0] = 1.;(*initial point*)(*different initial point converge to different root*)
    Table[x[i + 1] = x[i] - f[x[i]]/f'[x[i]]; x[i], {i, 0, 10}]

{1., 2.73889, 2.36779, 2.40456, 2.40483, 2.40483, 2.40483, 2.40483,2.40483, 2.40483, 2.40483}

  x[0] = 5.;(*initial point*)
    Table[x[i + 1] = x[i] - f[x[i]]/f'[x[i]]; x[i], {i, 0, 10}]

{5., 5.54215, 5.52003, 5.52008, 5.52008, 5.52008, 5.52008, 5.52008, 5.52008, 5.52008, 5.52008}

$\endgroup$
1
  • $\begingroup$ thank you this was very helpful :) $\endgroup$
    – shatman
    Aug 20 '18 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.