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!

Solving equation with two unknowns?

  1. Dec 14, 2012 #1

    Okay, I have finally worked out a decent curve to work with which is in accordance with my previous post called "How to create a simple mathematical model".

    According to the attachment in this thread, I have deemed the following equation format as respective to the curve in my attachment.

    f(x) = x^ -ax + b

    I could be wrong about this... but it's what I think... please let me know if I am incorrect in my assumption.

    I have selected one coordinate in the curve which is (30, 124) and I would like to complete the equation above using this coordinate.

    So I tried:

    f(x) = x^ -ax + b
    124 = 30^ - 30a + b
    0 = 900 - 124 - 30a + b
    0 = 776 - 30a + b

    I don't quite remember how to solve for a and b. Can someone please show me how to solve this equation which has two unknowns!

    All help or tutorial links is appreciated!


    Attached Files:

    • C6.jpg
      File size:
      65.9 KB
  2. jcsd
  3. Dec 14, 2012 #2


    Staff: Mentor

    you need two equations for two unknowns so pick another point and do the same.

    then solve the first in terms of b ie b=
    then plug the b= stuff into the second equation
    the second should now contain only a values so solve for a
    lastly take the a you got (its a number) put into the b= equation and now you'll have b too​

    WAIT is your eqn a line eqn or is that x to some power -ax?

    Your graph doesn't show a line so is your equation really this?

    y = x -ax + b
    Last edited: Dec 14, 2012
  4. Dec 14, 2012 #3
    Hello jedishrfu,

    Thanks for replying.

    Okay, I tried it and the two equations worked out, but when I tried to get a third
    value by using the know values of a and b it didn't work !!!!

    When x = 6, according to graph, its supposed to be 101??

    Please view the mathematical work in the three attachments below!


    Attached Files:

  5. Dec 14, 2012 #4


    Staff: Mentor

    I'm confused by your initial equation:

    Is this your equation?

    y = x 2 -ax + b

    If so and you did your math correctly and the third point doesn't work then you don't have the correct equation.
  6. Dec 14, 2012 #5


    Staff: Mentor

    You need to write what you mean. Your function apparently is f(x) = x^2 -ax + b, based on your work in evaluating f(30) above.

    The caret symbol, ^, does NOT mean "squared". To write the square of x and the square of 30, write x^2 or 30^2, NOT x^ or 30^.
  7. Dec 14, 2012 #6
    No, as pointed out to me, my equation is:

    f(x) = x^2 - ax + b

    Based on the curve's appearance that's what I believe! For points (14,114) and (30,124) the math works out. But when I do it for point (6, 101) I get 300 ??? which is totally off??

    I don't think I have the wrong equation, but if I do have the wrong equation then how does one feel out the correct equation ?

  8. Dec 14, 2012 #7
  9. Dec 14, 2012 #8


    Staff: Mentor

    are you trying to find the right equation so you can program it into some device?

    If thats the case you could consider writing a table of points and then using interpolation to get intermediate values then you wouldn't need the equation at all.

    Basically you'd be converting the curve into a connect the dots with line segments and using interpolation. Not perfect but hey.
  10. Dec 14, 2012 #9


    User Avatar
    Science Advisor

    Why do you not have a coefficient on the x^2 term? Why should it be 1.0 x^2 rather than 0.9 x^2 or 1.1 x^2? If you put a coefficient on the x^2 term, that gives you three parameters to determine and you'll need at least three points to determine the curve uniquely.

    Why do you expect that having selected a particular member from a family of curves based on sampling two or three points (and thereby determining two or three parameters) that the remaining points will neccessarily fit to the curve that you have determined?

    For a polynomial equation like this, a "least-squares" regression may be usefully applied. Instead of fitting to two points exactly, you fit to n points so that the total deviation is minimized. For a least-squares regression in particular, what you try to minimize is the sum of the squared deviation of each point from the selected curve.

    Least squares fit to a quadratic function is a very standard thing to want to do. Google it.
  11. Dec 14, 2012 #10
    hi jedishrfu,

    I have a proximity sensor that detects 0-240" based on 0-135 steps of infra red light emitted by an LED. For my led, I have a current source that can go from 0 ma to approximately 40 ma. I can increment my current source in 135 steps. Therefore, when my current source is at 0 steps, I have 0 ma through the led and therefore the detector has a maximum detection range of 0".

    Every step I increment my current source, the current through the led increments exponentially from 0 ma to 40 ma. The relation in steps vs inches is the graph I plotted by doing measurements myself.

    So, as shown in the graphic curve, the coordinates are selected by the following observations:

    at 101 steps of current, there is enough infra red light generated from the led for the sensor to detect something at 6"...
    at 114 steps of current, there is enough infra red light generated from the led for the sensor to detect something at 14"...
    at 120 steps of current, there is enough infra red light generated from the led for the sensor to detect something at 22"...
    at 124 steps of current, there is enough infra red light generated from the led for the sensor to detect something at 30"...
    at 126 steps of current, there is enough infra red light generated from the led for the sensor to detect something at 38"...

    hence coordinates:

    (6, 101)
    (14, 114)
    (22, 120)
    (30, 124)
    (38, 126)

    Now, I will know perhaps two points as I did in my attempt to calculate the equation above! But from those two points, I may need to know how many need to know how many steps are required for odd distances such as, 7" or 18" or 24" etc...

    So based on one equation, I would like to use it to figure out the distance in inches related to any step value I want!!!

    And I am having trouble finding that equation for this particular curve!!!!

    This curve seems like a parabola no? Its a wide parabola, but nonetheless a parabola!!!!

    As you may have noted, I only need the left half of this parabola for my values plotted!

    I have an idea! Probably nothing new to you....... but ..... as jbriggs suggested, maybe I should try to solve for three unknowns of three different points!!!! like this:

    f(x) = ax^2 - bx + c

    and do what I did for two points except I do it for three points... would this work??

    again thanks for your help!
    Last edited: Dec 14, 2012
  12. Dec 14, 2012 #11


    User Avatar
    Homework Helper
    Education Advisor
    Gold Member

    You seem to have 5 data points. You need only to use 3 data points to make a quadratic fit, using the very simplest of linear algebra. Choose any 3 points, use them to make your system of 3 equations in which the coefficients will be the unknowns to find.
  13. Dec 14, 2012 #12

    Like this right? :

    f(x) = ax^2 - bx + c

    and I would solve for a, b, c like I did before for 2 unknowns right?

  14. Dec 14, 2012 #13


    Staff: Mentor

    This assumes it is a quadratic. The only way you'll know is if the remaining two points work when you plug them into equation.
  15. Dec 14, 2012 #14
    wow!!! this is a lot of work....

    its 4 times I started over lol!

    Not sure if I am doing this right... but let me continue!

  16. Dec 14, 2012 #15


    User Avatar
    Homework Helper
    Education Advisor
    Gold Member

    Which quantity do you want as independant variable, and which quantity do you want as the function? Your graph looks like it shows a quadratic fit, IF you choose Distance from LED Sensor as a function of Steps of Current.
    Last edited: Dec 14, 2012
  17. Dec 14, 2012 #16


    User Avatar
    Homework Helper
    Education Advisor
    Gold Member

    Your listed data points:
    Switch coordinates:
    (101, 6)
    (114, 14)
    120, 22
    124, 30
    (126, 38)

    This looks like about the upper half of a parabola based on your first graph.
    If you believe that the
    best fit will be quadratic, I would arrange the system like this, using first,
    last, and middle data points just to cover best possibilities:


    The unknowns are the coefficients, a, b, and c. You may for easier processing,
    form the matrix:
    [10201, 101, 1, 6]
    [14400, 120, 1, 22]
    [15876, 126, 1, 38]

    You may find reduced triangular form like
    [1 -0 0 0.073]
    [0 1 0 -15.287]
    [-0 -0 1 805.4947]
    ( used the page http://www.math.purdue.edu/~dvb/gaussian.php )
    Last edited: Dec 14, 2012
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook