ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/root.cal
Revision: 1.1
Committed: Sat Feb 22 02:07:21 2003 UTC (21 years, 1 month ago) by greg
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R0, rad3R5, rad3R6, rad3R6P1, rad3R8, rad3R9
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 {
2 root.cal - calculate zeroes of functions using Newton's method.
3
4 2/3/88
5 }
6
7 FTINY : 1e-12;
8
9 root(f, x0) = root2(f, x0, x0-f(x0)/lim(f1(f,x0)), nit);
10
11 root2(f, x0, x1, i) = if(i,
12 if(err-abs(x1-x0),
13 x1,
14 root2(f,x1,x1-f(x1)/lim(f1(f,x1)),i-1)),
15 0);
16
17 abs(x) = if(x, x, -x);
18 lim(x) = if(x, max(x,err), -max(-x,err));
19 max(a,b) = if(a-b, a, b);
20
21 f1(f,x) = (f(x+FTINY)-f(x-FTINY))/FTINY/2; { numerical derivative }
22
23 err = 1e-6;
24 nit = 100;