3
$\begingroup$

How can I plot

Sqrt[x - x^3]/(x^2 + 1) 

in all its domain?

Domain = FunctionDomain[{ Sqrt[x - x^3]/(x^2 + 1)}, x] 

Domain is : x <= -1 || 0 <= x <= 1

I tried

Plot[{Sqrt[x - x^3]/(x^2 + 1)}, {x, -100, -1}] 

but I really dont know how!

$\endgroup$
4
  • 2
    $\begingroup$ What are you asking?... $\endgroup$
    – garej
    Mar 29, 2016 at 19:05
  • $\begingroup$ I want to plot the function Sqrt[x - x^3]/(x^2 + 1) and I cant $\endgroup$ Mar 29, 2016 at 19:11
  • 1
    $\begingroup$ Plot[{Sqrt[x - x^3]/(x^2 + 1)}, {x, -10, 1}]? $\endgroup$
    – garej
    Mar 29, 2016 at 19:12
  • 1
    $\begingroup$ The curly braces are not necessary here. $\endgroup$ Mar 29, 2016 at 19:31

2 Answers 2

12
$\begingroup$

Here's one approach:

Plot[Sqrt[x - x^3]/(x^2 + 1), 
    Element[x, ImplicitRegion[FunctionDomain[{Sqrt[x - x^3]/(x^2 + 1)}, x], x]]]

enter image description here

$\endgroup$
6
  • $\begingroup$ Interesting! I wasn't aware you can use region specification directly on Plot like that. $\endgroup$
    – kirma
    Mar 30, 2016 at 4:36
  • $\begingroup$ BTW, I believe the pedantically correct way would be to write Element[{x}, ...]. Otherwise x is actually treated as an one-dimensional vector, and it might not always work as it should as a scalar. $\endgroup$
    – kirma
    Mar 30, 2016 at 4:40
  • $\begingroup$ There's probably some difference between x and {x} in Plot, but I don't know of any off the top of my head. If you find any, let me know. $\endgroup$ Mar 30, 2016 at 15:57
  • $\begingroup$ I suspect Plot does some magic with its argument, since it knows that it cannot be multidimensional vector, anyway. Normally there's a difference between x and {x} in these cases (and documentation indicates that {x} should be used), but now it seems impossible to spot from insides of Plot. $\endgroup$
    – kirma
    Mar 30, 2016 at 17:10
  • $\begingroup$ I know Plot does some magic with its argument. :-) $\endgroup$ Mar 30, 2016 at 19:25
5
$\begingroup$

I believe that you are looking for something like the following. It uses the Show function to combine the two plots.

Show[Plot[{Sqrt[x - x^3]/(x^2 + 1)}, {x, -10, -1}], 
 Plot[{Sqrt[x - x^3]/(x^2 + 1)}, {x, 0, 1}], PlotRange -> All]
$\endgroup$
2
  • $\begingroup$ @JMM, Plot[{Sqrt[x - x^3]/(x^2 + 1)}, {x, -10, 1}, AxesOrigin -> {-10, 0}] is enough $\endgroup$
    – garej
    Mar 29, 2016 at 19:23
  • $\begingroup$ @SofiaPazJimenezCastillo Don't forget to accept one of the answers by clicking the check mark. $\endgroup$
    – Jens
    Mar 30, 2016 at 2:33

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.