Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Three equations and three unknowns: fitting a function.

  1. Aug 9, 2013 #1
    Hi!

    I'm doing a project with sound, and exploring modulation.
    I got stuck on an intermediate step ... and can't solve a simple algebra problem.

    I have a wave, which I know the envelope is a perfect sine wave, and fits the following three equations:

    A * cos( ph1 ) = knownSlope1
    A * cos( ph2 ) = knownSlope2
    A * ( sin( ph2) - sin( ph1 ) ) = knownDeltaHeight

    I need to solve for A, ph1, and ph2, where all phases ph1, ph2, are in radians.
    All numbers are reals, nothing tricky....
    Even if I could solve for A, and know the difference between ph1 and ph2, that would be enough... but I can't figure it out.

    I've messed with this for about two hours, and am still stuck; but it's three equations in three unknowns, so it should be solvable with at least one solution....
     
  2. jcsd
  3. Aug 9, 2013 #2

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Let's tidy this up a bit - the knowns are ##m_1##, ##m_2## and ##h##:
    $$\text{(1)}\; A\cos\phi_1 = m_1\\ \text{(2)}\; A\cos\phi_2 = m_2\\ \text{(3)}\; A(\sin\phi_2-\sin\phi_2)=h$$

    Your problem is the trig functions ... you can try looking for a trig identity that can simplify things down for you. Or you can find two more equations and treat the trig functions themselves as unknowns.
     
  4. Aug 9, 2013 #3
    First, quick typo fix: the second ##\phi## should have subscript 1.

    andrewr, you could use pythagorean theorem along with (2) and (3) or (1) and (3) to solve for A in terms of ##\phi_1## or ##\phi_2## respectively, but you will still end up with a complicated equation. However, getting down to one variable (after putting A back into the other equation), you could use any numerical solver to give you an answer (or Newton's method on your own). There may be a better solution, but my trig has never been great.
     
  5. Aug 9, 2013 #4
    You can simplify this into a two by two system as follows:
    Let r = (m1+m2)/A. Let s = h/A. Let x = phi2 and let y = phi1.

    Then adding the first two equations and leaving the third alone, you get the simplified system:

    cos x + cos y = r
    sin x - sin y = s

    Just something that's easier to work with.

    Then use the sum to product formulas:
    http://en.wikipedia.org/wiki/List_o...#Product-to-sum_and_sum-to-product_identities

    With t = half the sum of phi1 and phi2 and u = half the difference of phi1 and phi 2.

    This gives us:
    2cos(t)cos(u) = r
    2sin(u)cos(t) = s

    Dividing the second equation by the first, we get: tan(u)= s/r and then you have the difference of the phases.

    Hope that helps,
    Junaid Mansuri
     
    Last edited: Aug 10, 2013
  6. Aug 10, 2013 #5

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Try setting ##\alpha = \frac{1}{2}(\phi_2-\phi_1)## and ##\beta = \frac{1}{2}(\phi_2+\phi_1)## and use the sum-to-product relations. It helps to rewrite (1)-(3) so they are trig-only on the LHS ... I'll start you off:

    $$\text{(4)}\; \sin\phi_2-\sin\phi_1 = 2\sin\frac{\phi_2-\phi_1}{2}\cos\frac{\phi_2+\phi_1}{2}=2\sin\alpha\cos\beta =\frac{h}{A}\\
    \text{(5)=(2)-(1)}\; \cos\phi_2-\cos\phi_1 = \frac{m_2-m_1}{A} = \cdots\\
    \text{(6)=(2)+(1)}\; \cos\phi_2+\cos\phi_1 = \frac{m_2+m_1}{A}= \cdots $$

    You may be able to divide the equations between each other to get ##\tan\alpha## and ##\tan\beta## in terms of things you know.

    [edit]junaid beat me to it...
     
  7. Aug 10, 2013 #6
    Much better!

    Yes he did, and a fine job, too! :)
    However, I still need to solve for the amplitude, A.

    He gave r and s in terms of divided A; which results in s/r being independent of amplitude.
    But the equations for s and r, require knowing both x and y; aka phi2, and 1. not just the difference ...
    So, I can't back substitute directly and solve for A....

    Hmmm....
    I am going to need one more relationship...
    I'm going to sleep on it... perhaps I'll see it by morning. :)
     
  8. Aug 10, 2013 #7

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    If you have x and y then you have r and s.
    You know h - it's a given - so why not use A=h/s ?

    No? if you have ##\phi_1## and ##\phi_2## then just use (1) or (2)?
     
  9. Aug 10, 2013 #8
    I think the issue he is having is that he has half the difference of phi1 and phi2 but does not know what they are specifically.

    Here are some thoughts:
    - It is true that s/r is independent of amplitude and using the tangent relationship, it follows that phi2 - phi1 = 2arctan(r/s) = 2arctan((m1+m2)/h). Note that phi2 > phi1 in the way that we formulated the problem. We could have switched x and y and gotten the opposite inequality, it really doesn't matter.
    - Let phi2 - phi1 = D (which we will know numerically).
    - Then phi2 = phi1 + D and we can reduce the number of variables in the original problem to only two: A and phi1.
    - The system then becomes:
    A cos y = m1
    A cos (y+D) = m2

    The second equation can be expanded to:
    A(cos(y)cos(D) - sin(y)sin(D)) = m2

    Let cos(y) = v. Then we have:
    Av = m1
    A(v cos(D) - sqrt(1-v^2)sin(D)) = m2
    Dividing these two equations we get:
    v/(v cos(D) - sqrt(1-v^2)sin(D)) = m1/m2
    which is an equation in only one variable.
    Cross multiplying you get:
    v m2 = m1 v cos(D) - m1 sqrt(1-v^2) sin(D)
    v (m1 cos(D) - m2) = (m1 sin(D))sqrt(1-v^2)
    (sqrt(1-v^2))/v = (m1 cos(D) - m2)/(m1 sin(D))
    (1-v^2)/v = ((m1 cos(D) - m2)/(m1 sin(D)))^2
    The RHS of this equation is a constant. Once you find it, you can easily solve for v by using the quadratic formula. Then y = arccos(v).

    If you can use a numerical solver however, you can directly solve:
    (cos y)/cos(y+D) = m1/m2 for y. Once you know y which is phi1, we know that phi2 = y + D and A = m1/cos(y).
     
  10. Aug 10, 2013 #9

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Well if he only uses your two then sure - you left off the third equation: cosx-cosy=w ... but I provided that in post #5.
     
  11. Aug 10, 2013 #10
    You're right. I think using the other equation you made would make things easier. Applying sum to product with that equation you'd get -2sin(t)sin(u) = (m2 - m1)/A
    Dividing this equation by the second one I had before, you get:
    tan(t) = (m1 - m2)/h which you can use to find t.

    Then knowing the sum of phi1 and phi2 and their difference you can find both of them. You do have to be careful about the order of the difference and be consistent otherwise you might be off by a negative in one of your equations.

    Junaid Mansuri
     
  12. Aug 10, 2013 #11

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    That's how I had it in post #5 ... though I left a lot of the working out so that andrewr could have a go ;)
     
  13. Aug 10, 2013 #12
    :) I have been trying... and I wouldn't have gotten it with just the information in post #5. :(
    I was able to work it all the way through, finally, today.
    Thank you both.
     
  14. Aug 11, 2013 #13

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Yeah - I wrote post #5 specifically to make you work harder at it before providing additional hints.
    There was sufficient information in there to do it. The lynchpin was to split the phi angles into a sum of two - you needed to know the trig relation or, at least, know to google for a list of them.

    The trouble with this sort of thing is trying not to undermine the point of doing the exersize ... actually giving you all three equations turns it into pure algebra. You need to get used to approaching problems where you don't know how to proceed, without having to be told exactly how to proceed: it's what you are training for.

    That trick of turning two variables into two others by half-sum and half-difference is very common in physics - you will see it again and again.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Three equations and three unknowns: fitting a function.
Loading...