Linear Interpolation
Try using Linear Interpolation to solve x^3 + x^2 - 1 = 0.
The initial interval (0, 1) will lead to the answer x = 0.755 (correct to 3 dec pl) after 6 iterations, since 1 is quite near to the answer.
The initial interval (0, 2) will lead to the answer after 19 iterations.
The interval (1, 2) will not lead to the correct answer, since f(1) & f(2) are both +ve.
Exercises for students
Solve the following problems on paper and check your answers using the above applet:
Use linear interpolation on the interval [0, 1] to solve 2 sin(x) - 1 = 0, giving your answer correct to 3 decimal places.
Try the intervals [0, 2], [-1, 2], [0, 3].
Use linear interpolation on the interval [1, 2] to solve sin(x) - x + 1 = 0, giving your answer correct to 2 decimal places.
Summary
xn = |
a | f(b) | + b | f(a) | |
| f(b) | + | f(a) | |
You can define the equation using the following operators:
+ | - | * | / | ^ |
| sqrt( ) | ln( ) | exp( ) | pi |
| sin( ) | cos( ) | tan( ) |
| asin( ) | acos( ) | atan( ) |
| sinh( ) | cosh( ) | tanh( ) |
Right-click here to download the Java Class File and unzip the Javathings Math Package.
This applet uses the com.javathings.math package developed by:
Patrik Lundin
patrik@javathings.com
http://www.javathings.com