View Full Version : Algebraic Equation Solver
dd_vuong
03-07-2003, 12:08 AM
This code solves algebraic equations with complex coefficients
up to cubic orderview (http://dd_vuong.tripod.com/online/PCOMPLEXEQ.HTM)
You familiar with Newton's method?
You can approximate (rather accurately though) roots of equations, as long as you know the derivative. (In a pinch, you could try a numerical derivative, but then you're losing accuracy).
Basically, it is a :
function getRoot(guess) {
var old;
do {
old = guess;
guess = guess - f(guess)/fprime(guess);
} while (Math.abs(guess-old) > 0.0005);
return guess;
}
Depending on what you pass guess, it will find a root, or in the case of certain functions (like sinusoidal waves), oscillate forever, among other things. (In theory forever, the floating point arithmetic of a pc will eventually lose enough precision that it will converge somewhere).
dd_vuong
03-10-2003, 10:51 PM
The algorithm uses the analytic solution to cubic equation and so
is exact. It is an attempt to make use of JavaScript as a development platform on par with say Fortran or C. It is fascinating to put JS in this context. Consider the following.
JS does not have to be HTML "helper", but is used to develop stand-alone desktop applications with internet connectivity (loading functions from remote sites). It can be run locally or delivered via HTML page (distributed computing). It uses HTML
as GUI platform. And it has the enviable priviledge of being the
beneficiary of the latest internet technolgy.
kwhubby
03-15-2003, 11:11 AM
doesnt every body pretty much know that dd vuong?? (what you said that javascript is and can be)
you read that in intorductions on information of Javascript
ps. wow!! thats a really complex thing to me, never heard of cubic equation.
p.p.s you can do functions like function abc() {
instead of var abc = function(){
never thought about doing functions your way.
dd_vuong
03-17-2003, 09:46 PM
Hi Kris,
agree with you that almost all Javascripters are aware of these
issues. But only a tiny development work in JS is being done in this
direction. JS is still pretty much in evolution.
A1ien51
03-18-2003, 07:21 AM
Quick question: Why the buttons and not text boxes??
If you want to see my Math based program I am working on, you can see it here:
http://www10.brinkster.com/a1ien51/FEA/
Right now it is only IE, always code in IE first and get testing done, and then do netscape.
A1ien51
kwhubby
03-18-2003, 08:45 PM
dd : yeah that would be really cool if other aplications of javascript was more common!.
always code in IE first and get testing done, and then do netscape.
thats what i do, but alot of the times i never get to the point of making it multi browser supported
dd_vuong
03-19-2003, 08:43 PM
alien: I had problem with multiple user input nodes (prone to
human error). This novel use of buttons allow me to set one input
text field and distribute the input values to different variables.
It's supposed to be a design stepup.
Looked at your site and liked the layout. One comment: you should use scientific notation for your number outputs (it's hard to count many 0's). One question: finite-element-analysis approach uses system of linear equations (emphasis on "linear"), correct?
A1ien51
03-19-2003, 11:13 PM
I am going to add that to it later on, I was trying to get out the buigs in my code. I am actually working on a very different approach to solve FEA problems that uses alot of other things. FEA is a linear in a way and other ways not. It is a lot of matrix multiplication and maniplulation. This has become my area of interest of late, trying to get a job in this field.
I have the code done with allowing the user to input 200E9 into a field and have it read as 200000000000. and the same with the output, but with work and my other projects, have not incorporated it into the code yet.
A1ien51
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.