0
$\begingroup$

New to Mathematica and have been given some assignments for practice.

I am currently trying to plot the following function:

$$|\sqrt{x-1}+5|$$

This is how other sites show what this graph should look like:

Example graph

But trying to plot the same function in Mathematica gives the following unexpected graph:

unexpected graph

That straight line coming in from the left shouldn't be there, and no matter how I try to re-organize the plot function it seems to stay.

Am I misunderstanding something? Am I using the Plot function wrong? Thanks for any help and apologies if this is a noob question!

$\endgroup$
0
5
$\begingroup$

Use RealAbs instead of Abs since Abs is a Complex function. And the Sqrt is also a Complex function, sometimes we use Surd instead of Sqrt or Power

if we assume x is a real numbers,we can use ComplexExpand to observe the expression of Abs[Sqrt[x - 1] + 5]

Abs[Sqrt[x - 1] + 5] // ComplexExpand

(*  Sqrt[(5 + ((-1 + x)^2)^(1/4) Cos[1/2 Arg[-1 + x]])^2 + 
 Sqrt[(-1 + x)^2] Sin[1/2 Arg[-1 + x]]^2] *)

So we had to use another way.

Plot[RealAbs[Surd[x-1,2]+5],{x,-5,5},AxesOrigin -> {0, 0}]
$\endgroup$
1
  • $\begingroup$ Amazing comment, thanks for the help! My whole study group appreciates it. $\endgroup$ Sep 24 '20 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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