Pages

Tuesday, November 15, 2005

Simple equation II

x^N-1000*x+999=0

No wonder Matlab wouldn't get a right solution... with the approximation x=1+e, e is found to be 2*(1000-N)/N(N-1), which is close to 0 when N is close to 1000 (the values I was most ly interested for. Bad choice of parameters :-)

This equation arises as a solution to a very simple problem: Suppose you have an interval [a,b] and you need to create a sample grid of N points (i.e. , choose N points between a and b). BUT, I don't want a linear grid but a logarithmic instead, because I want my grid points to be concentrated around some value between a and b. My first choice was OK, let's chose an initial interval dz, and the next interval will be x*dz, the next one x^2*dz etc (x>1), until the sum of all these segments sums up to L=b-a=1. Then for a given dz (in my case dz=0.001) x is found to be the solution of the above polynomial.

Anyways this geometric progression doesn't do it: The value of x is so close to 1 that the intervals are almost linearly changing. Logarithmic (logspace in Matlab) doesn't do it either: In order to achieve the necessary accuracy and resolution I have to have millions of points. So I ended up writing my own logarithmic function, which goes like dz(i)=10^((x^i-1)*dz), for i=1..N and I played around with dz and x in order to get a nice result. Now I believe I have something, I put in my code and soon enough I will know how good it is or not.

Categories