Ask Your Question
0

What am I doing wrong with this function

asked 2014-09-26 12:54:31 +0100

nerak99 gravatar image

updated 2014-09-26 14:05:25 +0100

tmonteil gravatar image

I want to plot a function and its inverse. I issue

F=plot ((2*(x^3-2)),-4,0)
G=plot(sign(0.5*x+2.0)*abs(0.5*x+2.0)^(1/3),-4,0)
F+G

Now 2(x^3-2) is the inverse of (0.5x+2)^(1/3) (I even checked with a well known alternative to sage).

The plots come out with the scale of 2(x^3-2) all wrong. They should (obviously) be reflections in y=x.

Any help much appreciated

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2014-09-26 14:39:08 +0100

tmonteil gravatar image

updated 2014-09-26 14:39:44 +0100

Let me denote 2*(x^3-2) by f and sign(0.5*x+2.0)*abs(0.5*x+2.0)^(1/3) by g.

Since f and g are inverse to each other (on the whole real line), there is a symmetry of the whole graphs with respect to the line {x=y}, but you do not see it.

First, you need to have the same scale for x and y axes, you can get this by setting the option aspect_ratio=1.

Second, you look at the interval [-4,0] for both functions while this interval is not invariant: f([-4,0]) is not equal to [-4,0], so the graph of g on [-4,0] has no reason to be symmetric of the graph of f on [-4,0]. If you want to see the symmetry, you need to plot the graph of g on the image of [-4,0] by f.

sage: f = 2*(x^3-2)
sage: g = sign(0.5*x+2.0)*abs(0.5*x+2.0)^(1/3)
sage: f(-4)
-132
sage: f(0)
-4
sage: F = plot ((2*(x^3-2)),-4,0, aspect_ratio=1)
sage: G = plot(sign(0.5*x+2.0)*abs(0.5*x+2.0)^(1/3),-132,-4, aspect_ratio=1)
sage: F+G

So, you can see that f:[-4,0] -> [-132,-4] is a bijection whose inverse is g: [-132,-4] -> [-4,0].

The plot is even nicer for the map f:[-3,3] -> [-58,50]:

sage: f(-3)
-58
sage: f(3)
50
sage: F = plot ((2*(x^3-2)),-3,3, aspect_ratio=1)
sage: G = plot(sign(0.5*x+2.0)*abs(0.5*x+2.0)^(1/3),-58,50, aspect_ratio=1)
sage: F+G

Conclusion : maps are not only formulas, but require domain and codomain to be well defined !

edit flag offensive delete link more
0

answered 2014-09-26 13:03:32 +0100

nerak99 gravatar image

Duh, I haver to restrict the range on the first function. Sorry

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-09-26 12:54:31 +0100

Seen: 426 times

Last updated: Sep 26 '14