I would like to make a program which solves for an unknown in an equation, which seems easy to do on paper, but I have no idea how to make the computer do it.
Here's an example: I start with a string: v=u+a*t
If I solve for a, the result should be:
a=(v-u)/t
If I solve for u, the result should be:
u=v-a*t
etc.
jmsrickland is right, I want to be able to rewrite one function so that there's a different variable on the left, so that the computer can solve for any variable from one equation assuming that the others are given.
P.S. If you know about a solution in another programming language (which is not very complicated), that would be enough as well, as I only need the general idea, not the actual code.
P.P.S.: For now I only work with "easy" functions, which means that the only operators that are allowed: +-/*() and one = sign. All the rest are variables or numbers. Only one variable is unknown. If it could substitute one equation into the other, it would be a bonus, but I think that's too hard for now.
Here's an example: I start with a string: v=u+a*t
If I solve for a, the result should be:
a=(v-u)/t
If I solve for u, the result should be:
u=v-a*t
etc.
jmsrickland is right, I want to be able to rewrite one function so that there's a different variable on the left, so that the computer can solve for any variable from one equation assuming that the others are given.
P.S. If you know about a solution in another programming language (which is not very complicated), that would be enough as well, as I only need the general idea, not the actual code.
P.P.S.: For now I only work with "easy" functions, which means that the only operators that are allowed: +-/*() and one = sign. All the rest are variables or numbers. Only one variable is unknown. If it could substitute one equation into the other, it would be a bonus, but I think that's too hard for now.