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]
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}]}]
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.
and
{Plot[Tan[x], {x, -5, 5}, ExclusionsStyle -> Red],
Plot[Abs@Tan[x], {x, -5, 5}, ExclusionsStyle -> Red]}
ExclusionsStyle
spec for infinite singularities, no matter what the signs.
$\endgroup$
Commented
Aug 17, 2022 at 13:39
Plot[{h[x], Cancel[h'[x] h[x]]}, {x, -2, 6}, PlotStyle -> {Blue, None}, ExclusionsStyle -> {{Red, Red}}]
.
$\endgroup$
Commented
Aug 17, 2022 at 14:29
Exclusions
seems to work fine. What's wrong with it? $\endgroup$