home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
oct93
/
graphics
/
graphtal.lha
/
Graphtal
/
Examples
/
sqrt.lsys
< prev
next >
Wrap
Text File
|
1992-10-30
|
526b
|
35 lines
/*
* L-system for square root computation.
*
* No graphical output is generated, so use
* the following command line:
*
* graphtal -p -d no sqrt.lsys
*
*/
lsystem SQRT;
table Iteration
{
const epsilon = 0.00001;
Sqrt(r) -> Sqrt(5,1,r,0);
Sqrt(Xnew, Xold, r, n)
: abs(Xnew-Xold)/abs(Xold) >= epsilon
-> Sqrt(0.5*(Xnew+r/Xnew), Xnew, r, n+1);
};
table Result
{
Sqrt(Xnew, Xold,r,n)->Resultat(Xnew) IterationsUsed(n);
};
attributes {
axiom Sqrt(2);
derivation Iteration(infinity), Result;
};