ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/root.cal
Revision: 1.2
Committed: Sat Sep 4 19:26:09 2010 UTC (13 years, 8 months ago) by greg
Branch: MAIN
Changes since 1.1: +2 -1 lines
Log Message:
Minor updates

File Contents

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