0

So I'm trying to knock out this last problem, and I'm following my teacher's guide but my graph seems to still be off, the problem is:

Use the FindRoot command in Mathematica to define an inverse function g(y) to y = f(x) = 3x + tan(x) with the restriction ‑pi/2 < x < pi/2. Use x = tan-1(y) as a starting value. Then use the Plot command to make a graph of g(y).

This is how I wrote it out:

g[y_] := x /. FindRoot[3 x + Tan[x] == y, {x, ArcTan[y]}]

Plot[g[y], {y, (-Pi/2), (Pi/2)}]

I'm not sure exactly what the problem is, but it shows the graph as just being a straight line through the origin. I'm not sure if this is how it's supposed to be (which I assume it's not), but any and all help would be much appreciated!

Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125
  • 2
    Your real problem here is simply the y range: x is restricted on interval +/-Pi/2, y is not. Expland plot range on y to say +/- 20 for a more interesting plot. – agentp Sep 26 '13 at 14:32

1 Answers1

1

Having your equation,

3 x + Tan[x] == y

You can check the correctness of the plot of g(y) by plotting y(x):

Plot[3 x + Tan[x], {x, -.4, .4}]

As you can easily see, it is a straight line through the origin. g(y) is inverse of y(x) by definition, so you can get a plot of g(y) it just by exchanging the y and x axes:

    Plot[3 x + Tan[x], {x, -.4, .4}, 
  PlotRange -> All] /. {x_Real, y_Real} :> {y, x}
Alexey Popkov
  • 9,355
  • 4
  • 42
  • 93