Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Today in class we were shown how to create an infinite limit graph (plot) given the preceding conditions. While I have a fairly terrible sketch of this graph in my notebook, I'd like to create a clean version with Mathematica to import into my notes.

Here were the conditions:

$$ \begin{align*} g(2)&=1\\ g(5)&=-1\\ \lim_{x\to4}g(x)&=-\infty\\ \lim_{x\to-7^-}g(x)&=\infty\\ \lim_{x\to-7^+}g(x)&=-\infty\\ \end{align*} $$

Any help would be appreciated!

share|improve this question
1  
What do you mean by "infinite limit graph?" It is not a phrase I have encountered before. –  rcollyer Sep 20 '12 at 18:31
    
I'm new to calculus so I don't quite understand the differences yet. The teacher said that a/the difference between infinite limits (this chapter) and limits going to infinity (next chapter) was that as of right now we're not dealing with the ends of the lines in our graph. Once they touch the point we don't know where, if anywhere, they go to. –  Caminek Sep 20 '12 at 18:42
    
Aren't there an infinite number of possible functions that meet those conditions... –  s0rce Sep 21 '12 at 20:21
add comment

1 Answer

up vote 15 down vote accepted
g[x_] := 1/Abs[x - 4] + 1/(x + 7);
sol = Solve[a g[2] + b  == 1 && a g[5] + b == -1, {a, b}];
g1[x_] := (a g[x] + b) /. sol; 
Plot[g1[x], {x, -12, 8}, Evaluated -> True, 
     Epilog -> {Red, PointSize[Medium], Point[{{2, 1}, {5, -1}}]}]

Mathematica graphics

Edit

How to build these kind of things?

Answering the comments by the OP, I'll try to sketch up how one can build up this kind of functions.

First thing to note is that you can construct a divergence at $x_0$ simply by

$f(x) = \frac1{x-x_0}$ or $f(x) = \left|\frac1{x-x_0}\right|$ depending on the type of divergence you want to get. Let's see one example:

GraphicsGrid[
  Table[Framed@
           Plot[sign f, {x, -2, 2}, PlotRange -> {{-2, 2}, {-4, 4}}, 
                PlotLabel -> Style[Framed[sign f], 11, Blue, Background -> Lighter[Yellow]]],
  {sign, {-1, 1}}, {f, {1/(x - 1), 1/Abs[x - 1]}}]]

Mathematica graphics

Now, by adding up two of those, with different poles, we get a function with two divergences, like the one posted above. Let's see another example of that:

Framed@Plot[1/(x - 1) + 1/(x - 3), {x, -1, 4}]

Mathematica graphics

See? We got our function with two divergences at x = {1, 3}.

But you still have an additional requirement, because your function has two clamped values.

$$ \begin{align*} g(2)&=1\\ g(5)&=-1\\ \end{align*} $$

For doing that we add two degrees of freedom to the function: a scale (elongation) and an offset. Let's see what kind of things we can do with that:

Framed@GraphicsRow@{
  Plot[Table[a (1/(x - 1) + 1/(x - 3)), {a, 1, 3, .5}], {x, -1, 4}, 
    Evaluated -> True, 
    PlotLabel -> Style[Framed[Scaling], 14, Blue, Background -> Lighter[Yellow]]],
  Plot[Table[a + 1/(x - 1) + 1/(x - 3), {a, 1, 3, .5}], {x, -1, 4}, 
    Evaluated -> True, 
    PlotLabel -> Style[Framed[Offsetting], 14, Blue, Background -> Lighter[Yellow]]]}

Mathematica graphics

The way to add that freedom is to build a new function with two additional parameters a and b.

$g(x) =\frac{a}{(x-3) (x-1)}+b$

However, although it's easy, I'm not going to demonstrate here that by doing this, and finding appropriate values for a and b, which is the objective of our Solve[] trick in the original incarnation of this answer, you can clamp any two values. Do it as an exercise!

(Hint:

sol = Solve[a g[x0] + b == y0 && a g[x1] + b == y1, {a, b}]

)

Some food for thought

If you want to investigate it further, you can think why the following is able to clamp three points. Please note the function is not squared but cubed below ... and think Why? :

f[x_] := 1/Abs[x - 4] + 1/(x + 7);
g[x_] := a f[x]^3 + b f[x] + c
sol = Solve[g[2] == 1 && g[5] == -1 && g[-10] == 0, {a, b, c}];
g1[x_] := g[x] /. sol;
Framed@Plot[g1[x], {x, -12, 8}, Evaluated -> True, 
  PlotRange -> {{-12, 7}, {-4, 4}},
  Epilog -> {Red, PointSize[Medium], Point[{{2, 1}, {5, -1}, {-10, 0}}]}]

Mathematica graphics

share|improve this answer
    
Thank you! This was exactly what I was looking for! –  Caminek Sep 20 '12 at 18:49
2  
@user2353 but ... do you understand the code? –  belisarius Sep 20 '12 at 18:56
    
I don't fully understand the code: what does the option Evaluated -> True accomplish? The code works fine without it. I note that, while the option appears in the list generated by Options[Plot], the option is not listed on the documentation page ref/Plot. –  murray Sep 20 '12 at 19:06
1  
@murray You're right, it isn't needed in the current code incarnation. And it is not documented, but was reported previously in this site. See for example mathematica.stackexchange.com/a/7832/193 –  belisarius Sep 20 '12 at 19:10
1  
@user2353 Go on, edit your profile and put there a meaningful name! I am editing the answer to explain the "mental process" of the contraption. –  belisarius Sep 23 '12 at 18:29
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.