0
$\begingroup$

See the code below with the mentioned problem in the title.

f[x_]:=x^4-2x^3+2x-2;
g[x_]:=x^3-3x+2;
Plot[f[x]/g[x],{x,-2,6},
   PlotStyle->{Blue},
   Exclusions->{x^3-3x+2==0},
   ExclusionsStyle->{Red,Red},
   AspectRatio->Automatic]
   
$\endgroup$
1
  • 1
    $\begingroup$ Actually, Exclusions seems to work fine. What's wrong with it? $\endgroup$
    – Michael E2
    Commented Aug 17, 2022 at 13:20

1 Answer 1

1
$\begingroup$

When the signs are the same

Because

Solve[{x^3 - 3 x + 2 == 0, -2 < x < 6}, x]

{{x -> 1}, {x -> 1}}

and

Clear[f,g,h];
f[x_] = x^4 - 2 x^3 + 2 x - 2;
g[x_] = x^3 - 3 x + 2;
h[x]=f[x]/g[x];
Sign@Limit[h[x],x -> 1,Direction -> "FromBelow"]
Sign@Limit[h[x], x -> 1,Direction -> "FromAbove"]

-1 -1

It means that the function h[x]=f[x]/g[x] have the same sign -∞ and -∞ (same direction) when x->1- and x->1+,so it cann't determint the infiniteline(need to use two points,but -∞ and -∞ are the same)

We have to add this infinite line manually.

Clear[f,g,h];
f[x_] = x^4 - 2 x^3 + 2 x - 2;
g[x_] = x^3 - 3 x + 2;
h[x]=f[x]/g[x];
Plot[h[x], {x, -2, 6}, PlotStyle -> {Blue}, 
 AspectRatio -> Automatic, 
 Epilog -> {Red, Dashed, InfiniteLine[{1, 0}, {0, 1}]}]

enter image description here

When the signs are not the same

We can also compare with

Clear[f, g, h];
f[x_] = x^4 - 2 x^3 + 2 x - 2;
g[x_] = (x - 1) (x^2 + 1);
h[x_] = f[x]/g[x];
Sign@Limit[h[x], x -> 1, Direction -> "FromAbove"]
Sign@Limit[h[x], x -> 1, Direction -> "FromBelow"]
Plot[h[x], {x, -2, 6}, AspectRatio -> Automatic, 
 ExclusionsStyle -> Red]

-1 1

-∞ and can determint a infiniteline, the ExclusionsStyle work.

enter image description here

and

{Plot[Tan[x], {x, -5, 5}, ExclusionsStyle -> Red], 
 Plot[Abs@Tan[x], {x, -5, 5}, ExclusionsStyle -> Red]}

enter image description here

$\endgroup$
2
  • $\begingroup$ Perhaps WRI should add ExclusionsStyle spec for infinite singularities, no matter what the signs. $\endgroup$
    – Michael E2
    Commented Aug 17, 2022 at 13:39
  • 2
    $\begingroup$ You can get the asymptote added semi-automatically with Plot[{h[x], Cancel[h'[x] h[x]]}, {x, -2, 6}, PlotStyle -> {Blue, None}, ExclusionsStyle -> {{Red, Red}}]. $\endgroup$
    – Michael E2
    Commented Aug 17, 2022 at 14:29

Your Answer

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

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