John Veteran Posted January 23, 2004 Veteran Share Posted January 23, 2004 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 More sharing options...
username Posted January 23, 2004 Share Posted January 23, 2004 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 More sharing options...
John Veteran Posted January 23, 2004 Author Veteran Share Posted January 23, 2004 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 More sharing options...
Intelligen Posted January 23, 2004 Share Posted January 23, 2004 i'd solve for y, so y = ?x + ? then input that back into y so your all in terms of x and solve Link to comment Share on other sites More sharing options...
markwolfe Veteran Posted January 23, 2004 Veteran Share Posted January 23, 2004 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 More sharing options...
John Veteran Posted January 23, 2004 Author Veteran Share Posted January 23, 2004 :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 More sharing options...
HellBender Posted January 23, 2004 Share Posted January 23, 2004 7(3x + 12.5 - 22.5) = 5(4.2x - 6.3y - 30) 3x + 12.5y = 22.54.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 More sharing options...
John Veteran Posted January 23, 2004 Author Veteran Share Posted January 23, 2004 :huh: no, i don't, but i've got a much better chance of seeing it in 10 hours :D Link to comment Share on other sites More sharing options...
dreamz Veteran Posted January 23, 2004 Veteran Share Posted January 23, 2004 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 More sharing options...
dreamz Veteran Posted January 23, 2004 Veteran Share Posted January 23, 2004 ahh, the matrices aren't clear. the first 2x2 matrix has 4 elements, 3, 12.5, 4.2, and -6.3. the second 2x1 matrix has x and y, and the third 2x1 matrix has 22.5 and 30. Link to comment Share on other sites More sharing options...
John Veteran Posted January 23, 2004 Author Veteran Share Posted January 23, 2004 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 More sharing options...
xWeston Posted January 23, 2004 Share Posted January 23, 2004 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 More sharing options...
markwolfe Veteran Posted January 23, 2004 Veteran Share Posted January 23, 2004 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 More sharing options...
John Veteran Posted January 23, 2004 Author Veteran Share Posted January 23, 2004 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 More sharing options...
dreamz Veteran Posted January 23, 2004 Veteran Share Posted January 23, 2004 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 More sharing options...
kongit Posted January 23, 2004 Share Posted January 23, 2004 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 More sharing options...
Recommended Posts