This example is to solve for a root of an equation using the Newton Rapson method. This involves determining the slope of a line at a point, determining the X-Intercept of the line, and using that in a recursive role to determine an actual root. The program did not attempt to trap for equations with imaginary roots, and required that the user input an appropriate seed to start the process with.
A little education is provided to the user regarding degree's of Equations, and allows the user to choose not only degree 1 thru 6, but can choose up to 9 degree equations to solve for.
Once the user input a Value, the screen is blanked, and part of it redrawn, but this time with the equation example as requested, as well as a request for the constants.
This is culminated with a print out of the Function and Derivative. I contemplated not allowing the "+ +" when a constant is zero, but decided it was not worth the effort, and that this emphasised the fact there was no X constant.
After inputting a number to start with, the equations are solved to determine the root as shown:
As noted, 2*1.41^2 = 4, solving the equation. The equations (Function and Derivative) are shown below: