Method of False Position

Author

Eric W. Weisstein
May 6, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumericalMath/MethodofFalsePosition.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/MethodofFalsePosition.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

FalsePosition[f_,{x_,x1_,x2_},n_:1]:=Module[{l={x1,x2}},
	 Do[
			l=Append[l,x1-(l[[-1]]-x1)/(f[l[[-1]]]-f[x1])f[x1]],
			{i,n}
		];
		l
]

FalsePositionFigure[f_,{x_,x1_,x2_},n_:1,opts___]:=Module[
		{xi=FalsePosition[f,{x,x1,x2},n],solid,dotted,pts},
			solid=Flatten[Table[{{xi[[i]],f[xi[[i]]]},{xi[[i+1]],0}},{i,2,n+1}],1];
		dotted=Table[Line[{{xi[[1]],f[xi[[1]]]},{xi[[i]],0}}],{i,3,n+2}];
	 pts=Table[Point[{xi[[i]],f[xi[[i]]]}],{i,n+1}];
		Show[Plot[f[x],{x,x1,x2},PlotRange->All,DisplayFunction->Identity],
			Graphics[{{PointSize[.02],pts},Line[solid],{Dashing[{.02,.02}],dotted}}],
		opts,DisplayFunction->$DisplayFunction]
]

Figure

f1[x_]:=x^3+x^2
f2[x_]:=x^4-x^2
Show[GraphicsArray[{
			FalsePositionFigure[f1,{x,-1.5,1},6,DisplayFunction->Identity,Ticks->None],
			FalsePositionFigure[f2,{x,-1.1,.5},7,DisplayFunction->Identity,Ticks->None]}],
DisplayFunction->$DisplayFunction]