Application Center - Maplesoft

App Preview:

Iterative solution to changing problem

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Self-Adjusting Iterative Solution to Equations

1998 Waterloo Maple Inc.

NOTE: This worksheet demonstrates a symbolic approach to a numerical analysis problem.

Introduction

This worksheet demonstrates the flexibility of a symbolic approach to numerical analysis. It shows a bisection solution to an algebraic equation where the model itself is dependent on intermediate results of the iterative solution (i.e. the equation to solve changes during solution). This level of flexibility is very difficult to implement in traditional languages such as C or FORTRAN but is quite simple in Maple.

Define initial model structure

> restart;

Bisection problem

> f := (x-2)^3+a;

[Maple Math]

Solve using a simple bisection method and adjust model coefficient with each iteration.

> flag := 0; tol := .001; xl := 0; xr := 3; a := 1;

> for iter from 1 while flag <> 1 do
testpt := xl + (xr-xl)*.5;
test := subs(x=testpt,f);
if abs(test) < tol then flag := 1
elif test < 0 then
xl := testpt;
a := a+.01; print(`Adjusted function`,f);
else
xr := testpt;
a := a-.01; print(`Adjusted function`,f);
fi;
print(`Iteration`,iter,`Test value`,test);
od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> f;

[Maple Math]