hi all
i'm currently doing a-level maths, and am interested in how i can combine db and the things i learn in class. one thing which struck me was, is it possible to solve equations using db?, or any programming language come to that. take the following simultaneus equations:
5x+2y=25 and 2x+7y=41
(x=3 and y=5)
is there a way how you can write a program to solve such equations?
ie. could you do something to rearrange the equation to solve it?
the only way i can think of is a very inefficient way, which is as follows:
`Simultaneous Equations
`By Robin
sync on
sync rate 0
backdrop on
dim correctanswers#(2)
for y#=-10 to 10 step 1.0
for x#=-10 to 10 step 1.0
set cursor 0,0
print "X="; : print x#
print "Y="; : print y#
sync
correct=0
if (5*x#)+(2*y#)=25 and (2*x#)+(7*y#)=41 then correct=1
if correct=1 then correctanswers#(1)=x# : correctanswers#(2)=y# : print "ANSWER FOUND!" : exit
next x#
next y#
sync
set cursor 0,0
print "THE ANSWERS ARE: "
print "X="; : print correctanswers#(1)
print "Z="; : print correctanswers#(2)
sync
all i'm doing is a for next loop, checking the numbers from -10 to 10 for x and y, and it does work. this obviously wouldn't work for the majority of equations, as i'm only checking the integers and only within a certain range. i suppose i could increase the range and set the step to something like 0.01 or 0.001. this increases the probability of it finding the correct answers, but that takes absolutely ages to finish as there are millions of different combinations. and you could also get irrational numbers, which wouldn't work either.
sorry if i'm not making any sense or not seeing something, but i just want to know if it is possible to do it any other way
is there?