5
$\begingroup$

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!

$\endgroup$
3
  • 1
    $\begingroup$ What do you mean by "infinite limit graph?" It is not a phrase I have encountered before. $\endgroup$
    – rcollyer
    Commented Sep 20, 2012 at 18:31
  • $\begingroup$ 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. $\endgroup$
    – user2353
    Commented Sep 20, 2012 at 18:42
  • $\begingroup$ Aren't there an infinite number of possible functions that meet those conditions... $\endgroup$
    – s0rce
    Commented Sep 21, 2012 at 20:21

1 Answer 1

14
$\begingroup$
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

$\endgroup$
10
  • $\begingroup$ Thank you! This was exactly what I was looking for! $\endgroup$
    – user2353
    Commented Sep 20, 2012 at 18:49
  • 2
    $\begingroup$ @user2353 but ... do you understand the code? $\endgroup$ Commented Sep 20, 2012 at 18:56
  • $\begingroup$ 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. $\endgroup$
    – murray
    Commented Sep 20, 2012 at 19:06
  • 1
    $\begingroup$ @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 $\endgroup$ Commented Sep 20, 2012 at 19:10
  • 1
    $\begingroup$ @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. $\endgroup$ Commented Sep 23, 2012 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.