## Mathematica not plotting whole logarithmic function

4

1

I am trying to use the following input

Plot[Log[E,x+1],{x,-50,50},PlotRange->50]


however the output is:

How can I adjust it so the line goes down to the PlotRange mark specified. Or is this a limitation of Mathematica?

Your question is not especially original, it's going to be closed in a while. I'd do this: Plot[{Re@#, Im@#}&@Log[x + 1], {x, -50, 50}, Evaluated -> True, PlotStyle -> Thick], PlotRange serves a different purpose than you seem to expect, see documentation pages. – Artes – 2013-08-19T09:46:16.733

I just tried that and got the following: Link To Graph

– VikeStep – 2013-08-19T09:53:31.217

Does it make you wonder? If it does, start to learn complex functions, there are many helpful questions.

– Artes – 2013-08-19T09:59:30.483

I am assuming that its giving me the imaginary components when it is less than one, is there a way that i can forget about the imaginary bit and only show the real values? because even if I change the x value to be between -1 and 50, it still doesnt go all the way down to the bottom, also can you explain what Evaluated is doing, I can't find anything in the documentation – VikeStep – 2013-08-19T10:02:39.587

You can use Re@Log[x + 1] instead of {Re@#, Im@#}&@Log[x + 1]. – Artes – 2013-08-19T10:05:01.650

But are you sure the real part is what you want?... – Andrew Jaffe – 2013-08-19T10:06:19.577

@Artes OP can be in secondary school (probably he isn't but he can) and want to plot Log[x+1] and you are telling him to start learning complex functions if he want to achieve this in Mathematica :) – Kuba – 2013-08-19T10:07:04.573

Just saying, that there is no difference between my original graph and what is made by sticking Re@ in front of it... I know that when the y value is -20 for example that the x value should be $1/{e^{20}}-1$, however I can't see it on the graph – VikeStep – 2013-08-19T10:08:17.097

I have already learnt complex numbers, I am doing highest maths in grade 11, just didn't realise that was what I was graphing until he pointed it out. And I am sure I only want the reals. – VikeStep – 2013-08-19T10:09:46.900

2It's a problem of how Plot[] works. There is only one pixel per x-value, and the curve at x=-1 is so steep that it doesn't take up more than one pixel in width. Use this instead: ParametricPlot[{x, Log[x + 1]}, {x, -1, 3}, PlotRange -> {{-2, 3}, {-10, 2}}] – Volker – 2013-08-19T10:12:57.140

@Volker this is exactly, what I was looking for, thank you. EDIT: I notice that similar with Plot, it stops, its just that it is about 10, but using that info, I can just put an Epilog of a line on there to demonstrate where it is – VikeStep – 2013-08-19T10:15:09.907

Actually, the problem is still there when you put in larger numbers... but it's a little better. At that point I'd probably draw in a straight line manually, extending the curve. Check out the Graphics and Line commands. – Volker – 2013-08-19T10:18:58.663

@artes I believe the OP just wants to see more of the asymtote at x=-1. – Sjoerd C. de Vries – 2013-08-19T12:07:33.207

1@SjoerdC.deVries This poor question is not even a bit clear what the OP wants, why not e.g. Plot[Log[x + 1], {x, -2, 50}, PlotRange -> {{-2, 50}, All}] – Artes – 2013-08-19T12:23:29.650

@Artes I think you should post this as an answer. PlotRange is the most natural (but not obvious) solution. – Kuba – 2013-09-06T13:08:03.060

@Kuba It's been a long time since I haven't answered plotting tagged questions. I'm not especially interested in them. But if you believe there is something to add to the actual post, feel free to use all the comments above and beneath. – Artes – 2013-09-06T18:08:07.627

10

As I mentioned in the comments, it's a problem of Plot[]. Mathematica won't draw more than one pixel per pixel column. So I'd use ParametricPlot instead, which makes it a little better, but still not perfect. The line becomes so steep that you can't tell the difference between it and a straight line, so you just extend it manually:

ParametricPlot[{{x, Log[x + 1]}, {-1, -x - 9}}, {x, -2, 50},
PlotRange -> {{-2, 50}, {-50, 10}}, PlotStyle -> {Blue, Blue}]


1Works perfectly, I decided to use a method similar to this, I still used Plot, but I added

Epilog->Line[{{-1,-4},{-1,50}}]
 – VikeStep  – 2013-08-19T10:29:14.563

@user9053 I don't think your soulution is in any way similar to the one given here. – Sjoerd C. de Vries – 2013-08-19T12:59:53.733

what I'm saying is, is that he explained why it wasn't working and said that I should manually extend the line, so instead of manually extending it in ParametricPlot, I did it in Plot – VikeStep – 2013-08-20T07:21:02.190

1

This is what I'd do, the idea is to use ParametricPlot[{b^y, y}] for Log[b, x]. So we can use Solve to make it a little bit more general:

Block[{x, y},
With[{notimportantoptions = Sequence[PlotStyle -> Thick, PlotRange -> {All, {-25, 6}},
AspectRatio -> 1,  AxesStyle -> Arrowheads@.05,
AxesOrigin -> {0, 0}, BaseStyle -> {18, Bold}]
},

ParametricPlot[{x, y} /. Solve[y == 2 Log[15 + x], x, Reals][[1]], {y, -25, 6},
RegionFunction -> (# < 10 &), notimportantoptions, Evaluated -> True]
]]