Message Boards Message Boards

0
|
9671 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Need help with writing a code for arctan

Posted 9 years ago
POSTED BY: Sarah Schmidt
2 Replies

In $Mathematica$ it's much more direct than you might dream up, in this post Zero crossings and zero-almost crossings a code skeleton was given

 nsZ[f_, x0_, n_Integer: 100] := If[NumericQ[f[x0]],
          FixedPoint[(# - f[#]/f'[#]) &, N[x0], n],(*else*)
          Print["Function f = ", f, " is not numeric at x0 = ", x0]; 
          Return[$Failed]
       ]

$f$ is the function (e.g. ArcTan), $x0$ is the start value, the result is the zero position $x1$ (i.e. $f(x1) = 0$).

It might converge as well as diverge

 In[21]:= nsZ[ArcTan, #, 20] & /@ Range[0.1, 1.5, 0.1]
 Out[21]= {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.67686305871854*10^18082, 7.264574678709*10^111191}

divergency happens if the next Iteration Point has a derivative whose Tangent is more horizontal than the Tangent of the current Iteration Point.


Sorry for the silly capitalization of words, it is done automatically since today ...

POSTED BY: Udo Krause

enter image description here

POSTED BY: Simon Cadrin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract