Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

What is the code for this in Matlab or Mathematica using Newton's method?

Update:

Find the root of the following equation x-.08-.02sin(x)=0

1 Answer

Relevance
  • Melvyn
    Lv 7
    7 years ago

    Newtons Method boils down to

    x_new = x_old - f(x_old)/ f ' (x_old)

    where the function f(x)=0

    f(x) = x-0.08 -.02 sin x

    f ' (x) = 1-0.02 cos x

    Now we just need an initial guess ..I suggest x=0

    since we are repeating (iterating) the above calculation it suggests a "while" function being used until a certain criteria is met ie perhaps abs[x_new - x_old] <= 0.0001 ?

    of course if you want to show off , you could include a check that f '(x_old) didnt equal 0 too

    easier reply would be

    f[x_]:=x-.08-.02Sin[x];

    FixedPoint[#-f[#]/f'[#]&,0]

Still have questions? Get your answers by asking now.