View Single Post
  #6 (permalink)  
Old 09-26-2006, 02:19 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,569
Last Blog:
Tidy up your HTML
Credits: 0
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Quote:
Originally Posted by Lop View Post
hehe, that is what I was thinking.

So you have 2x=4 which means x=2? How do you have that in your code? Is it a string?

$variable = "2x=4"?

I do a substr on it, pull out the 2 and the 4 by getting the index of the X and the =. Once that is done, divide 4 variable by 2 variable.
sort of what i was saying, but i was thinking suppose the equation is dynamic and dependent on what the user enters. he can enter any degree equation and any ammount of terms he wants.

i suppose you could explode it at the equals sign then subtract the right side of the equation from the right side of the equation and set the equation equal to zero. from there you could apply the intermediate value theorum and newtons method (farly basic calc theorums) and iterate it a hundred times or so, if the output appears chaotic there is no answer ie) X^2 = -4 has no answer and the iterations will appear chaotic... if the iterations appear as an integer or appear to approach a single value (rational or irreational) that value is the answer... fairly complex process and would also require taking the derivitive of the equation which would require a complex algorythm in itself... but i suppose this would be the "fool proof" way of going about it..

edit
hell on second thought X^2 = -4 does have an answer 2i^2 but that would require another step to the program, but its seems pretty straight forward other than a bunch of checks/validations and indepth calculations... and since im learning java in my computer science class i may try to program this in java for fun because im weird like that

Last edited by John; 09-26-2006 at 02:27 AM.
Reply With Quote