Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21842

Program to solve for variable algebraically eg: v=u+a*t -> a=(v-u)/t

$
0
0
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.

Viewing all articles
Browse latest Browse all 21842

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>