Equations in Turing
Author |
Message |
Aange10

|
Posted: Tue Sep 27, 2011 8:52 pm Post subject: Equations in Turing |
|
|
What is it you are trying to achieve?
I'm writing a program for my Algebra 2 class that can solve a system of equations using substitution.
What is the problem you are having?
Well I really just have a question, but I've made a new thread so that any other help I need with this will be allocated at the same place (instead of my other topics).
My question is: Can turing do equations with undefined variables? For example, lets say that a client has input all the information he/she has, and the equation is Y = 1/2x + 8. Is there a way i could use the variable x in my solving without turing yelling that it is undefined?
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
To whom it may concern...
Turing: |
var y1, m1, x1, b1, y2, m2, b2, x2, y_answer, x_answer : real
var have_var : string
loop
put "Please insert your two equations in Slope Int form."
put "Formula: y1 = m1 * x1 + b1 y2 = m2 * x2 + b2."
put "If you have y1 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is y1?"
get y1
cls
else
end if
put "If you have m1 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is m1?"
get m1
cls
else
end if
put "If you have x1 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is x1?"
get x1
cls
else
end if
put "If you have b1 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is b1?"
get b1
cls
else
end if
put "If you have y2 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is y2?"
get y2
cls
else
end if
put "If you have m2 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is m2?"
get m2
cls
else
end if
put "If you have x2 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is x2?"
get x2
cls
else
end if
put "If you have b2 type 'yes', otherwise type 'no'."
get have_var
if have_var = "yes" then
put "What is b2?"
get b2
cls
else
end if
end loop
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: Tue Sep 27, 2011 9:05 pm Post subject: RE:Equations in Turing |
|
|
still don't understand what you are trying to do. A wild guess would be that you are looking to use Prolog instead of Turing. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
DemonWasp
|
Posted: Tue Sep 27, 2011 9:14 pm Post subject: RE:Equations in Turing |
|
|
No, there is no way to do this (easily). You could write what's called a "symbolic computation engine" (http://en.wikipedia.org/wiki/Symbolic_computation) like Maple (http://en.wikipedia.org/wiki/Maple_%28software%29), but that will be very involved and difficult. |
|
|
|
|
 |
Insectoid

|
Posted: Tue Sep 27, 2011 9:57 pm Post subject: RE:Equations in Turing |
|
|
You'd have to store the equation as a string and write the code to parse and calculate that string. Creating any type of calculator that solves complicated equations (ie anything 'bigger' than x*y) is very involved. |
|
|
|
|
 |
Aange10

|
Posted: Wed Sep 28, 2011 5:51 pm Post subject: RE:Equations in Turing |
|
|
What does involved mean? And what do you mean parse? Simplify (I live in the US)? I can do all the math required. I just am not sure how to code it |
|
|
|
|
 |
DemonWasp
|
Posted: Wed Sep 28, 2011 10:09 pm Post subject: RE:Equations in Turing |
|
|
"Involved" in this case is meant to suggest "a full university education" and probably "a fairly large team to help you build it". By "parse" I mean "completely decompose the input string into parts". The parts in this case would be literal numbers, like "3", variables like "x" and operators like "+"; from there, you have to build a "tree" out of these things based on operator precedence. Once you have that, you can start on the (difficult) work of solving the equation.
Since your examples are very simple (line equations, always as y = mx + b), you could just ask "which is your unknown, x, y, m or b?" and have them input the other three values, and based on that, you could solve for the answer. |
|
|
|
|
 |
|
|