I have been trying to write a program that symbolically solves simple algebraic equations. What I have now works fine, except when there is more than one instance of the variable that is being solved for. I cannot figure out how to combine variables. So my question is, is there an algorithm for symbolically solving equations available somewhere, and I just can't find it? Or do I have to keep banging my head against the wall?
symbolic equation solving?
Started by Witash, Mar 25 2007 02:33 PM
4 replies to this topic
#1
Posted 25 March 2007 - 02:33 PM
|
|
|
#2
Guest_Jordan_*
Posted 26 March 2007 - 03:38 AM
Guest_Jordan_*
Hello Witash, can you post the bit of code that you have in question?
#3
Posted 26 March 2007 - 02:54 PM
Well, I don't have much code at this point; i am still trying to work out an algorithm. Here is what i have so far in pseudocode:
to solve for x in an equation
split the equation into side1 and side2
while side1 != x
This will work as long as there is only one instance of x. But, I haven't been able to figure out how to combine the two sides if there is more than one instance of x. So, for example, y=2*x would work fine, and give you x=y/2. but y=x+x would not work with this method. in this case x+x needs to be combined into 2*x before the loop can continue, and that's the part i can't figure out.
*I didnt include how to find the next operation here to try to keep this short. I'm completely sure it works as designed though.
to solve for x in an equation
split the equation into side1 and side2
while side1 != x
nextop=next operation* of side1
split side1 into leftside and rightside, based on the position of the next operation
if x is ONLY in leftside
side1=leftside
side2=side2+the opposite of nextop+rightside
if nextop== - or /
side1=rightside
side2=leftside + nextop + side2
side1=leftside
side2=side2 + the opposite of nextop+ rightside
????combine the two sides????
end if end loopThis will work as long as there is only one instance of x. But, I haven't been able to figure out how to combine the two sides if there is more than one instance of x. So, for example, y=2*x would work fine, and give you x=y/2. but y=x+x would not work with this method. in this case x+x needs to be combined into 2*x before the loop can continue, and that's the part i can't figure out.
*I didnt include how to find the next operation here to try to keep this short. I'm completely sure it works as designed though.
#4
Posted 27 March 2007 - 08:26 AM
Depending on the language you are working with, it might be worth-while to try to create some classes for handling expressions. Then you could work out how to perform certain types of expressions as a sort of library.
I've thought about this sort of thing in the past (I was planning to make Java applets as a tutoring tool for students). If you can create classes for rational numbers, linear expressions, polynomials, etc, then you can define how to add, subtract, multiply, divide them. At that point, the x + x situation becomes an issue of an unsimplified linear expression and the class will handle it for you.
I've thought about this sort of thing in the past (I was planning to make Java applets as a tutoring tool for students). If you can create classes for rational numbers, linear expressions, polynomials, etc, then you can define how to add, subtract, multiply, divide them. At that point, the x + x situation becomes an issue of an unsimplified linear expression and the class will handle it for you.
#5
Posted 31 March 2007 - 02:24 PM
Thanks wingedpanther, i think that is probably the best way to do it, especially since i intend to use Java. From what I can see, It's still going to be complicated , but i agree that using classes will make it much more manageable.


Sign In
Create Account

Back to top









