View Single Post
Unread 03-21-2006, 05:13 PM   #10
Long Haired Git
Cooling Savant
 
Long Haired Git's Avatar
 
Join Date: Jan 2003
Location: Sydney, Oz
Posts: 336
Default Re: Units Converter & Equation Solver

Forums just ate my reply. %$#%#.

Anyhow, my method is brutal and not smart. Didn't consult any books or sites for "right way" or "smart way", just hacked up how I would do it when I was on the train to work as a way to make getting my approximator formulae.

I take the points, and substitute them into:
a.x.x.x + b.x.x + c.x + d = y

There's a checkbox to say that the point 0,0 (if supplied) is a "hard" point and that solves d = 0 immediately. All other points are assumed approximate (and 0,0 if checkbox not on) as I typically read my points off PQ graphs rather than real data.

So, I have a heap of formulae like:
{value}.a + {value}.b + {value}.c + {value} = 0

I then factor each where I can (ie, if each value is divisible by two etc) and only keep unique formulae.

Next, I substitute every formulae into every other formulae, factor and again only keep unique formulae created. I then repeat this again and again. Thus, my 6 or so points end up being, well, tens of thousands of formulae.

Next, I look for the formulae where a and b are near zero. These are then used to come up with a value for c by averaging all the c values. I then substitute the c value back into all the equations and go looking for where a is near zero and solve for b, and then repeat for a.

By "zero", I mean 0.000000001. I found this gives the same accuracy I need as using more decimal places but its much faster and using less decimals is no faster. On my computer on the day I mucked about.

So, supply it like 10 points and want cubic then I cap it at 100,000 formulae which it will get to.

Let me know if I am being dumb and there's a smarter way and if I get bored on the train, I may programme it up.

I've got some webspace now, but the issue is turning it into an applet (as in I have to find some train time).

Emailing you the code and classes BigBen2K, please don't distribute further, please don't post the source code, feel free to Applet-ise and host if you know java. Any other changes, please send them back so I can take advantage etc.
__________________
Long Haired Git
"Securing an environment of Windows platforms from abuse - external or internal - is akin to trying to install sprinklers in a fireworks factory where smoking on the job is permitted." (Prof. Gene Spafford)
My Rig, in all its glory, can be seen best here
AMD XP1600 @ 1530 Mhz | Soyo Dragon + | 256 Mb PC2700 DDRAM | 2 x 40 Gb 7200rpm in Raid-0 | Maze 2, eheim 1250, dual heater cores! | Full specifications (PCDB)

Long Haired Git is offline   Reply With Quote