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!

Finding the intersection of two functions via linearization

  1. Sep 2, 2012 #1
    At least I think it's via linearization.

    Let

    [itex]f(x) = \tan (x^2) - 1[/itex]

    and

    [itex]g(x) = \frac{\ln((x+1)^3)}{3}[/itex]

    Find the smallest positive and negative intersection with a relative error of less than 0.001.

    I don't know. You can linearize one or both, yeah, but you don't have any analytical value to compare it with, how would go determine the relative error? Can anyone put me on the right track?
     
    Last edited: Sep 2, 2012
  2. jcsd
  3. Sep 2, 2012 #2

    Bacle2

    User Avatar
    Science Advisor

    The concept of linearization I know of is one where you use the derivative

    to do a linear approximation to the function at a point. But I don't see how that

    fits here. How are you defining linearization?
     
  4. Sep 2, 2012 #3
    Well, eh, the same way. But I figured because you can't simply do [itex]f(x) = g(x)[/itex] you'd have to make an educated guess where they would intersect from a picture and then do a linear approximation in a point nearby, and solve the much easier equation.

    But yeah, I have no idea how you would determine the error. Perhaps it's not even via linearization as you say. I honestly have no idea how to begin. Perhaps with Taylor series?
     
  5. Sep 2, 2012 #4

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    First you have to linearize about a given point. Choose some reasonable value of x and linearize the two functions about that x value. Find where the linearized equations intersect. Use that value to linearize again. You can be sure the solution is within a given range of x if two consecutive solutions are. If you were to subtract the two equations and use this method to find where their difference is 0, you would be using "Newton's method".
     
  6. Sep 2, 2012 #5
    Ahh, that makes sense. Thank you!

    In case anyone is interested:

    [itex]0 = f'(x_0)(x - x_0) + f(x_0) - (g'(x_0)(x - x0) + g(x_0))[/itex]

    So that

    [itex]x_1 = \frac{f'(x_0)x_0 - f(x_0) - g'(x_0)x_0 + g(x_0)}{f'(x_0) - g'(x_0)}[/itex]

    I then plugged that in Maple; Wolframalpha confirms it gives the correct intersections.
     
  7. Sep 2, 2012 #6

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Why do you use Maple and then use Wolfram Alpha? Maple can do the whole job just fine.

    You are solving the equation F(x) = 0, where F(x) = f(x) - g(x), and are using Newton's Method
    [tex] x_{n+1} = x_n - \frac{F(x_n)}{F'(x_n)},\: n=0,1,2,\ldots [/tex]
    You need to be careful: Newton's Method can sometimes diverge instead of converging to the root of F(x) = 0. However, if the derivative F'(r) ≠ 0 at the root r of F(x) = 0 (so that x = r is not a multiple root), and if we start with x0 sufficiently near r, then we will get very rapid convergence to r.

    RGV
     
    Last edited: Sep 2, 2012
  8. Sep 2, 2012 #7
    To check whether it was correct. Maple did it just fine indeed, but I wanted to make sure :) Thank you everyone for your comment.
     
  9. Sep 2, 2012 #8

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    What I really mean is: why would you trust Wolfram Alpha but not trust Maple?

    RGV
     
  10. Sep 2, 2012 #9

    Bacle2

    User Avatar
    Science Advisor

    I'm betting Ray Vickson is Canadian :) . Any takers?
     
  11. Sep 2, 2012 #10

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Well, you're right, and before retiring I spent > 30 years at the University of Waterloo, where Maple was born. However: what does that have to do with the question I asked?

    RGV
     
  12. Sep 3, 2012 #11
    Because I wrote the Maple code to find the solution whereas with WolframAlpha I can just input [itex]f(x) = g(x)[/itex] and it'll generate it for me. I trust Maple to execute my code properly, but I don't assume my code to be correct - and I assume Wolfram's is :)
     
  13. Sep 3, 2012 #12

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    When I try Wolfram Alpha it does not generate code for me; it just gives a list of numerical solutions. When I do it in Maple (using 'fsolve' instead of 'solve') it gives me solutions one at a time; I can get a list of solutions either by using the 'avoid' option, or by giving a list of input intervals. For example:
    S0:=fsolve(eq,x);
    S0 := 0.
    S1:=fsolve(eq,x,avoid={x=S0});
    S1 := 0.6977070973
    S2:=fsolve(eq,x,avoid={x=S0,x=S1});
    S2 := 3.223162525
    This has missed the solution at 1.993, but if we narrow the search intervals it will work.
    S1:=fsolve(eq,x=S0+.01..S0+1);
    S1 := 0.6977070973
    S2:=fsolve(eq,x=S1+.01..S1+1);
    --> no solution, so increase the interval
    S2:=fsolve(eq,x=S1+.01..S1+2);
    S2 := 1.993218238
    S3:=fsolve(eq,x=S2+.01..S2+1);
    S3 := 2.683224142
    etc.

    In fact, before setting out on any halfway complicated equation-solving task it is a good idea to first plot the functions involved. This will easily allow you to see what is going on in this example.

    We could, of course, get more accuracy by increasing the 'digits' count:
    Digits:=20;
    fsolve(eq,x=0.001..1);
    0.69770709730287239774

    or
    Digits:=40;
    fsolve(eq,x=0.01..1);
    0.6977070973028723977363487530371501244775

    Admittedly, Wolfram Alpha (in *this* example) is a bit more convenient, because it gives a list of solution right away, while in Maple we have to work at it a bit.

    BTW: both Wolfram Alpha and Maple likely use a combination of methods, such as Newton's Method, Regula Falsi, the Secant Method or several others in an adaptive way, tailoring the method to perceived problem behaviour. However, the default is usually Newton's Method.

    RGV
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook