Which of the following ordered pairs represents the solution to the system given below? 2x + y = 20 4x − 2y = 40 A) (10,0) B) (0,10) C) (4,2) D) (10, -10)
If you are under pressure try brute force: Put for x the first number out of each of the pairs and the second for y into the first equation and see whether it fits. A successful candidate (for x and y) for the first equation is then used for the second as well. Once it has worked out for both you know which one it is.
For multiple choice it is often a quick solution. Be warned that your prof would probably prefer the elimination approach (Gauss) however.
And the bad retriceway of solving it is via formulating it as LP (linear programming) model. Here a sample (for Gurobi): def main(): pass if __name__ == '__main__': main() from gurobipy import * m = Model("mip1") x = m.addVar(vtype=GRB.CONTINUOUS, name="x", lb=-GRB.INFINITY, ub=GRB.INFINITY) y = m.addVar(vtype=GRB.CONTINUOUS, name="y", lb=-GRB.INFINITY, ub=GRB.INFINITY) m.update() c1 = m.addConstr(2 * x + y == 20, name="1") c2 = m.addConstr(4 * x - 2 * y == 40, name="2") m.update() m.setObjective(x, GRB.MAXIMIZE) m.optimize() print "_________________________________________________________" if m.Status == GRB.OPTIMAL: m.printQuality() m.printAttr('x') m.printAttr(['lb','ub']) print('Obj: %g' % m.objVal) print ('FeasibilityTol: %g' % m.Params.FeasibilityTol) print "\nConstraint checkup:" for c in m.getConstrs(): row = m.getRow(c) LHS = row.getConstant() for i in range(row.size()): LHS += row.getCoeff(i) * row.getVar(i).X if((c.Sense == '=')) & (abs(c.RHS-LHS)>m.Params.FeasibilityTol) | (c.Sense=='<') & (LHS>c.RHS+m.Params.FeasibilityTol) | ((c.Sense=='>') & (LHS<c.RHS-m.Params.FeasibilityTol)): print "Violation in constraint " + c.ConstrName + ": LHS = " + str(LHS) + ", RHS = " + str(c.RHS) else: print "LHS: " + str(LHS)+ " consists of: " for i in range(row.size()): print " " + str(row.getCoeff(i)) + ' * ' + str(row.getVar(i).X) print "________" else: print m.Status
Here is the output of your problem. I've replaced the value for X through XXXXXXX. Which way would you like to go? *** Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32. *** >>> *** Remote Interpreter Reinitialized *** >>> [Dbg]>>> Optimize a model with 2 rows, 2 columns and 4 nonzeros Coefficient statistics: Matrix range [1e+00, 4e+00] Objective range [1e+00, 1e+00] Bounds range [0e+00, 0e+00] RHS range [2e+01, 4e+01] Presolve removed 2 rows and 2 columns Presolve time: 0.05s Presolve: All rows and columns removed Iteration Objective Primal Inf. Dual Inf. Time 0 1.0000000e+01 0.000000e+00 0.000000e+00 0s Solved in 0 iterations and 0.05 seconds Optimal objective 1.000000000e+01 _________________________________________________________ Solution quality statistics for model mip1 : Maximum violation (unscaled/scaled): Bound : 0.00000000e+00 / 0.00000000e+00 Constraint : 0.00000000e+00 / 0.00000000e+00 Dual : 0.00000000e+00 / 0.00000000e+00 Variable x ------------------------- x XXXXXXXXXXXXXX Variable lb ub -------------------------------------- x -1e+100 1e+100 y -1e+100 1e+100 Obj: 10 FeasibilityTol: 1e-06 Constraint checkup: LHS: 20.0 consists of: 2.0 * 10.0 1.0 * 0.0 ________ LHS: 40.0 consists of: 4.0 * 10.0 -2.0 * 0.0
im so lost
As a hint: By looking at the first equation it is obvious that you have to have for x something that when doubled would equals to 20 and at the same time the y should have no impact at all. The A is already quite good candidate therefore (y = 0 and x would give you 20 when doubled). Can you verify, you know just in case...
The test to verify that A is the solution could look like this: A: x = 10; y = 0; Your equations as follows: 2x + y = 20 4x − 2y = 40 We substitute the x and y through the values we suspect would fit: 2 * 10 + 0 = 20 4 * 10 − 2 * 0 = 40 Can you calculate and check that the terms are really equal to 20 and 40 resp? If do I would be confident that A is what you are looking for.
Have to go... I hope it helps. I will have a look in ~10 hours again. Good luck!
You just made it more confusing for the asker .-.
-2(2x + y = 20) 4x − 2y = 40 Keep in mind opposites cancel out :) -4x-2y=-40 -4x-2y=-40
im really lost @kidrah69
We did the Elimination method
Opposites cancel :) do u kinda get it?
not really
Look at this http://www.coolmath.com/algebra/12-2x2-systems-of-equations/03-solving-by-elimination-addition-01
get it? :-)
Join our real-time social learning platform and learn together with your friends!