Changeset 84
- Timestamp:
- 08/01/06 02:35:00 (2 years ago)
- Files:
-
- trunk/mathextra/RealAnalysis.d (modified) (2 diffs)
- trunk/mathextra/ieee.d (added)
- trunk/test.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/mathextra/RealAnalysis.d
r82 r84 154 154 155 155 unittest { 156 int numCalls; 156 157 real cubicfn (real x) { 158 ++numCalls; 159 if (x>float.max) x = float.max; 160 if (x<-double.max) x = -double.max; 157 161 return 0.386*x*x*x + 23*x*x + 15.7*x + 525.2; 158 162 } 159 160 163 void testbrent(real delegate(real) f, real x1, real x2) { 161 164 real result = findRoot(f, x1, x2); … … 175 178 testbrent( (real x) { return sin(x); }, 6, 90); 176 179 testbrent(&cubicfn, -100, 100); 177 // This case performs extremely poorly, requiring 2000 iterations to converge. 178 // I think there may be a problem with the algorithm. 179 testbrent(&cubicfn, double.max, -double.max); 180 numCalls = 0; 181 // This case performs extremely poorly, requiring 17000 iterations to converge. 182 // The algorithm needs a logarithmic binary chop for these cases. 183 testbrent(&cubicfn, real.max, -double.max); 184 writefln("Num calls = ",numCalls); 180 185 } 181 186 trunk/test.d
r82 r84 17 17 import mathextra.mathutil; 18 18 import mathextra.leastsqr; 19 import mathextra.ieee; 19 20 20 21 import std.stdio;
