ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/root.cal
Revision: 1.3
Committed: Tue Oct 11 15:40:54 2011 UTC (12 years, 6 months ago) by greg
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R2P1
Changes since 1.2: +3 -3 lines
Log Message:
Changed default epsilon values

File Contents

# User Rev Content
1 greg 1.3 { RCSid $Id: root.cal,v 1.2 2010/09/04 19:26:09 greg Exp $ }
2 greg 1.1 {
3     root.cal - calculate zeroes of functions using Newton's method.
4    
5     2/3/88
6     }
7    
8 greg 1.3 FTINY : 1e-9;
9 greg 1.1
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 greg 1.3 err = 1e-5;
25 greg 1.1 nit = 100;