[pstricks] psNewton

Markus Krebs markuskrebs at web.de
Wed Apr 13 08:18:20 CEST 2011

Hi Users, especially Herbert!

It may be useful for teaching to have a psNewton-macro

Like \psFixpoint[linecolor=blue]{9.5}{sqrt(5*x)}{20}

\psNewton[linecolor=blue]{Starting Point}{Function}{Steps}
\psNewton[linecolor=blue]{-15}{f(x)}{10}

Minimal Example (all things done by hand)

\documentclass{article}
\usepackage[dvipscolor]{xcolor}
\begin{document}

\def\f{ \string -(1/192)*x^3-(1/12)*x-(1/192)*\psPi*x^2-(1/12)*\psPi+2}

\SpecialCoor
\psset{plotpoints=2000,unit=0.5,algebraic}%
\begin{pspicture*}(-20,-10)(8,20)
%
\psgrid[subgriddiv=1,gridlabels=0pt,gridcolor=lightgray]
%
\psaxes[Dx=6,Dy=4]{->}(0,0)(-20,-10)(8,20)[$x$,270][$y$,0]
%
\psplot[algebraic,linewidth=1.0pt,linecolor=blue]{-20}{10}{\f}
%
\psxTick(-15){x_0}
%
%-15, -9.567466932, -4.903526029, 3.026073041, 6.688396612, 5.580230655

\psset{linecolor=red}

\psline[linestyle=dashed](-15,0)(*{-15} {\f})
\psline[linestyle=solid](*{-15} {\f})(-9.567466932,0)
%
\psline[linestyle=dashed](-9.567466932,0)(*{-9.567466932} {\f})
\psline[linestyle=solid](*{-9.567466932} {\f})(-4.903526029,0)
%
\psline[linestyle=dashed](-4.903526029,0)(*{-4.903526029} {\f})
\psline[linestyle=solid](*{-4.903526029} {\f})(3.026073041,0)
%
\psline[linestyle=dashed](3.026073041,0)(*{3.026073041} {\f})
\psline[linestyle=solid](*{3.026073041} {\f})(6.688396612,0)
%
\psline[linestyle=dashed](6.688396612,0)(*{6.688396612} {\f})
\psline[linestyle=solid](*{6.688396612} {\f})(5.580230655,0)

\end{pspicture*}
\end{document}

Problems:

Division by zero-problem.
oscillating -> No problem, because of the given steps
wrong root --> user problem

Markus