<- previous index next ->
Project writeup Did you use a plotting utility to look at the shape of the function? Did you use a grid search to find candidate staring points? 0.0025 works, yet 0.001 will get you into the global minima well. The global minimum must be between -3 and -4 by analysis of equation. Did you refine your grid search to get a set of four surrounding values greater than the lowest minimum value found so far? * ^ * | | | | * *=f(x,y) | * | | | | | | | | * | | | | | | | | | (x,y) | | | | | | | (x,y-dy) (x,y+dy) | | | (x-dx,y) (x+dx,y) (Refine means closing in on local xmin=x-dx, xmax=x+dx, ymin=y=dy, ymax=y+dy as well as reducing the step size dx, dy.) Given a good candidate staring point, use an available minimization to find the local minimum value that should be the global minimum value. To get high accuracy, 100 digits, requires that the function be evaluated using multiple precision, covered in an earlier lecture. Typically, if 100 digit accuracy is desired, then all computation would be performed at 110 to 200 digit accuracy. This is slow yet not difficult for sin(x) and exp(x) for small values of x. exp(x)=1 + x + x^2/2! + x^3/3! + x^4/4! + ... For |x|<1 you need the nth term where n! > 10^110 or n=75 Similarly for sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... Similarly for cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ... For sqrt(x) make a guess y=1, then iterate y=(y+x/2)/2 until |y-y_previous| < 10^110 Actually, not quite that easy. You must use range reduction to get |x|<1 and better if |x| < 1/2. e.g. for sin(x): if abs(x)>2Π then x=x rem 2Π if x>&Pi then x=x-2Π if x<&Pi then x=x+2Π if x>Π/2 then x=Π-x if x<&Pi/2 then x=Π+x now abs(x)<Π/2 1.57 use sin(x)=2 sin(x/2) cos(x/2) on x/2<Π/4 0.78 Several of the implementations to 200 digits, that I have programmed: generic_digits_arithmetic.adb mpf_sin_cos.c Obviously, you find a good staring point with global search and and then use a reasonable optimization method to get a good starting x,y before going to multiple precision computation. Project writeup
<- previous index next ->