Two of my homework problems don't want to get plotted.. I keep getting empty graphs with only the two axes:

enter image description here

And for the second one:

enter image description here


In[114]:= Clear[h]

In[177]:= h[x_]:=(1-Log[x])/(E^(1/x))
In[178]:= Limit[h[x], x->0, Direction->FromAbove]
Out[178]= ConditionalExpression[0,ln∈&&Log[e]>0]
In[179]:= Plot [h[x],{x, 0, 4}]

Second one:

In[133]:= Clear [g]
In[180]:= Limit[g[x], x-> 0, Direction-> FromAbove]
Out[180]= ∞
In[181]:= Plot [g[x],{x, 0, 3}]
  • 7
    $\begingroup$ Use Log instead of ln and E instead of e, and brackets [] instead of parentheses () for functions. $\endgroup$ – Carl Woll Oct 31 '18 at 1:17
  • 1
    $\begingroup$ Be patient... post the code in text format $\endgroup$ – J42161217 Oct 31 '18 at 1:18
  • 1
    $\begingroup$ As in @CarlWoll's hint, Mathematica is case sensitive and built-in functions are capitalized. $\endgroup$ – Chris K Oct 31 '18 at 1:25
  • $\begingroup$ I added the text version $\endgroup$ – Youssef Oct 31 '18 at 1:41
  • 1
    $\begingroup$ Nvm fixed. Thanks enano $\endgroup$ – Youssef Oct 31 '18 at 2:15

Not to do your homework for you, I have made an edit to your first problem to make it work (changed the numbers so you have to implement it yourself, but it should give an idea).

(* Use () instead of [] for ordering *)
h[x_] := (13 - Log[5 * x])/E^(1 / x^2);

Now you can look at why Direction wasn't working properly for you. If you read the error message and look at the documentation for the Limit function you will see that FromAbove is not a supported value, nor is it something that Mathematica even knows about.

(* the values of the Direction option are + or - 1, you can play around with the below *)
Limit[h[x], x -> 0, Direction -> -1]

Then with the above modifications, the Plot call evaluates properly.

(* this just works with the modifications to h[x_] *)
Plot[h[x], {x, 0, 4}]

Things to take away:

  1. The coloring of things in a notebook can give you hints about what is going on. The fact that FromAbove was blue means that it doesn't have a value.

  2. When a message is issued, read it carefully and try to figure out what it means. Google and other resources are your friend.

  3. Read about WL syntax, square brackets [] are only for calls to/defining functions, not for ordering expressions, use regular parens for that ().

  4. Good luck on your homework! Try to watch some Mathematica/Wolfram Language instructional videos. In fact Stephen Wolfram has an excellent guide to starting to use the language. It is available from free online right here at this link.

| improve this answer | |
  • 1
    $\begingroup$ Works! Thanks a lot! $\endgroup$ – Youssef Oct 31 '18 at 2:16
  • 2
    $\begingroup$ "FromAbove" is equivalent to -1 and "FromBelow" is equivalent to +1 (Note: presence of quotes) $\endgroup$ – Bob Hanlon Oct 31 '18 at 2:50
  • $\begingroup$ Thanks @BobHanlon, I often find it frustrating when I can't remember if a value needs to be string-valued or a symbol. This was one of those cases. I could swear I had seen them before, but clearly the symbol FromAbove was not defined. Thanks for pointing that out! $\endgroup$ – enano9314 Oct 31 '18 at 4:57

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