solve 2 equations with 2 unknowns


Recommended Posts

i should be able to do this, but it's not the easiest problem... i have two equations, listed below. i need to solve for x and y. btw, this is for a computer science class. i'm making a program that takes 2 equations and solves for the two unknowns. don't worry about the coding, i can do that just fine... it's just my math is unusually weak for some reason :blink: also, i already have a program that works when the x and y are added but not subtracted... :/ and i already triple checked these equations, they're typed exactly as they're shown on my worksheet.

3x + 12.5y = 22.5

4.2x - 6.3y = 30

i used a website (http://www.webmath.com/solver2.html) to give me the answers so i had an idea about what to do, but the answers weren't what i expected at all :blink: x = 7.23739 and y = 0.0630271 :huh: i thought they would be integers...

my teacher told us to use cramer's rule, which is stated below. this works excellent when everything is added, and like i said above, the trouble comes in when something is subtracted...

a*X + b*Y = constant

c*X + d*Y = constant

if this seems to hard for you, please let me know :laugh: also, don't beat yourselves up trying to solve this, i'm going to ask my math teacher tomorrow anyway, even though he teaches calculus :unsure: thanks in advance to anyone who helps (Y)

Link to comment
Share on other sites

you need to cancel out one number by reducing, then solve for the single remaining unknown, then plug it in to the original to get the 2nd unknown...

what grade are you in by the way?

Link to comment
Share on other sites

i set the two equations equal to each other, multiplying the first by 7 and the second by 5 so that the x coefficients were equal.

7(3x + 12.5 - 22.5) = 5(4.2x - 6.3y - 30)

21x + 87.5y - 157.5 = 21x - 31.5y - 150

then, i solved for y, getting 0.06302521, which is close to what the webmath website gave me, but not exact...? :blink:

still working on it...

edit: i'm in my second semester of college :laugh: :/ i just haven't done this in a few years...

Link to comment
Share on other sites

The solution to this is a matter of:

a) converting one formula into terms of ONE variable:

aX + bY = C will become X = (C - bY)/a

b) substitute the (C - bY)/a value in place of X in the other equation

c) with the second equation now in terms of one variable ('Y'), you can solve for Y

d) with Y solved, plug that constant into either original formula, and solve for X

done. :D

[EDIT: replaced how ( Y ) became (Y) in item c]

Link to comment
Share on other sites

:happy: i get it now, thanks guys.

... that was easy :blink: i remember doing this, so i'm gonna go to sleep and look at my notes in the morning. thanks again guys (Y)

Link to comment
Share on other sites

7(3x + 12.5 - 22.5) = 5(4.2x - 6.3y - 30)
3x + 12.5y = 22.5

4.2x - 6.3y = 30

Therefore, 7(22.5) = 5(30), 157.5 = 150.. Brilliant.

Hope you saw your flaw there..

Link to comment
Share on other sites

hey guys, the easiest way is to use matrices.

just look and set it up like this.

|3 12.5| |x| = |22.5|

|4.2 -6.3| |y| = |30|

where | | represents a matrix. so you have a 2x2 multiplied by a 2x1 equaling another 2x1.

why does this work? you set up the system so it's ax = b. if you multiply both sides by the inverse of a (the 2x2), you get a^-1*ax = a^-1*b

and since a^-1*a = the identity matrix, it simplifies to:

x = a^-1*b

so put the first and third matrices in your calculator, find a^-1 and multiply it by b. that's it.

Link to comment
Share on other sites

hey guys, the easiest way is to use matrices.

just look and set it up like this.

|3 12.5| |x| = |22.5|

|4.2 -6.3| |y| = |30|

where | | represents a matrix. so you have a 2x2 multiplied by a 2x1 equaling another 2x1.

why does this work? you set up the system so it's ax = b. if you multiply both sides by the inverse of a (the 2x2), you get a^-1*ax = a^-1*b

and since a^-1*a = the identity matrix, it simplifies to:

x = a^-1*b

so put the first and third matrices in your calculator, find a^-1 and multiply it by b. that's it.

that would work, but i can't just "put the first and third matrices in my calculator" :/ i have to be able to code it, which means solve by hand without a calculator...

Link to comment
Share on other sites

that would work, but i can't just "put the first and third matrices in my calculator" :/ i have to be able to code it, which means solve by hand without a calculator...

Using matricies would be the easiest way to solve it.... Ever heard of "Multi-dimensional arrays" ? They are exactly what you want to use.

Link to comment
Share on other sites

Using matricies would be the easiest way to solve it.... Ever heard of "Multi-dimensional arrays" ? They are exactly what you want to use.

My goodness, this is taking me back to my college days. :pinch:

I remember solving augmented matrices for 3 variable equasions like so:

ax+by+cz=d

ex+fy+gz=h

ix+jy+kz=l

becomes:

| a b c d |

| e f g h |

| i j k l |

and you needed to do simple math on the numbers to get:

| 1 0 0 x' |

| 0 1 0 y' |

| 0 0 1 z' |

where the solutions to x, y, & z are x', y', & z'.

I remember it being easy to do, but I haven't used it since then! LOL :rofl:

Link to comment
Share on other sites

yes, i've heard of multi-dimensional arrays, but we can't use them :/ :hmmm:

well i think i've made enough of a fool of myself for one night :blush: goodnight everyone :sleep:

Link to comment
Share on other sites

i don't know anything about coding programs, but i can say this:

1. you can use the substitution technique to do it by hand. solve for one, then the other.

2. you can mulitply one equation by a constant and add (or subtract) the equations to eliminate one variable. solve for one, then solve for another.

3. use matrices. you don't need any calculator actually, since these are just 2x2 matrices. the inverse of a 2x2 is simple (and i assume coding the process would be simple as well).

but i have no idea how you want this done since i don't know how to code. :p :laugh:

Link to comment
Share on other sites

people can't do their own homework :no:

take the first equation and solve it for a variable like so: y=(22.5 - 3x)/12.5

then since you know y plug it into the second like so:

4.2x - 6.3((22.5 - 3x)/12.5) = 30

solve for x. then put that number for x into either original and get y

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.