1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Approximately solve system of equations

  1. Jul 2, 2014 #1
    I have a 3 variable system of equations (no solution) and am trying to solve for variables of an Ax = b to be as close to b as possible without changing A.

    28446757643x + 82500000y + z = 13557300
    283009432x + 283009432y + z = 10264100
    14180045548x + 82500000y + z = 3651510

    I am fiddinling around trying to solve in R but there are no exact solutions and I cannot figure out how to approximate the variables to give the closest values to the other side of the equation. Eventually this is all going in excel, so if there is a Solver way to handle this that might just be easier to use.

    Any help is appreciated, thanks!
  2. jcsd
  3. Jul 2, 2014 #2


    User Avatar
    Science Advisor

    Those are linear equation with integer coefficients- there certainly are "exact solutions". The solutions are rational numbers so can be written as fractions. Subtracting the second equation from the first gives 25606748211x- 200509432y= 3293200. Subtracting the second equation from the third gives 13897036116x- 200509432y= -6612590. The arithmetic is tedious but very basic.
  4. Jul 2, 2014 #3

    So I was just trying to see if there was a trend in this 3x3 subest of the entire matrix which is 266x3 :yuck:

    So I guess to rephrase my problem, I will have 266 equations with 3 variables and that is why I want to approximate the variables as close as possible and examine the outliers. Is there a way in excel or R to automate this process that anyone could think of? Sorry if this sounds all over the place, it's been a while since I've had to do real math outside of school without being given equations haha. Thanks!
  5. Jul 2, 2014 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    It's not clear from where you develop these 266 equations, but you have an overdetermined system of linear equations. Such a system arises often in doing a linear regression on a set of data. You write an equation in the unknown linear coefficients for each data point in your data set, and then you want to find the linear coefficients which minimize the error between the regression line and the data points.


    The traditional method to solve such systems is to form the so-called 'normal equations'.

    You start with the matrix equation:

    Ay = b,

    where A is an n x m rectangular matrix, and y and b are n x 1 column vectors. To form the normal equation, multiply both sides by the transpose of matrix A:

    [itex]A^{T}A y = A^{T}b[/itex]

    The product [itex]A^T A[/itex] is a matrix with n rows and n columns [edit: corrected size of normal matrix], and in theory the resulting normal equations could be solved using standard techniques, like Gaussian elimination, for example.

    However, for reasons too technical to discuss here, solving the normal equations can lead to inaccurate results due to round off error in floating point calculations. Fortunately, different numerical methods have been developed which help to minimize loss of accuracy due to floating point errors. One of these is called the QR factorization or QR decomposition:


    The QR method allows you to factor the original overdetermined system without needing to form the normal equations. It's one of the more useful developments made by numerical analysis in the 20th century, IMO.
    Last edited: Jul 2, 2014
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted