Message Boards Message Boards

[✓] Plot rational functions?

GROUPS:

Please, could any body help me? I want to plot graphics of elementary rational functions like f(x)=1/x, or g(x)= (x^2+1)/(x^2-4), what I got is not correct. I have tried to indicate the intervals of the domain of the function with inequalities but it does not work, for instance for g(x): -6<x<-2, -2<x<2, 2<x<6. I understand is a problem with x values that make zero the denominator. I attach a file with the examples. Thank you very much.


Plot[f[x] = 1/x, {x, -6, 6}, PlotStyle -> Directive[RGBColor[1, 0, 0], AbsoluteThickness[2.25], 
Arrowheads[{-.05, .05}]], GridLines -> {Range[-6, 6, 1], Range[-6, 6, 1]}, 
Ticks -> {Range[-6, 6, 1], Range[-6, 6, 1]}] /. Line -> Arrow

enter image description here

Plot[f[x] = (1 + x^2)/(-4 + x^2), {x, -6, 6}, PlotStyle -> Directive[RGBColor[1, 0, 0], 
AbsoluteThickness[2.25], Arrowheads[{-.05, .05}]], GridLines -> {Range[-6, 6, 1], Range[-6, 6, 1]}, 
Ticks -> {Range[-6, 6, 1], Range[-6, 6, 1]}] /. Line -> Arrow

enter image description here

Attachments:
Answer
21 days ago

You can use Exclusions:

Plot[(1 + x^2)/(-4 + x^2), {x, -6, 6}, 
  PlotStyle -> 
   Directive[RGBColor[1, 0, 0], AbsoluteThickness[2.25], 
    Arrowheads[{-.05, .05}]], Exclusions -> (-4 + x^2) == 0] /. 
 Line -> Arrow
POSTED BY: Gianluca Gorni
Answer
21 days ago

The problem is the f[x]= in the function to be plotted. Try it with a plain expression or define the function outside Plot. (Plot analyzes the expression passed for discontinuities, but it apparently does not handle the case when the expression is of the form Set[f[x], expr].)

Either

Plot[(1 + x^2)/(-4 + x^2), {x, -6, 6}, 
  PlotStyle -> 
   Directive[RGBColor[1, 0, 0], AbsoluteThickness[2.25], 
    Arrowheads[{-.05, .05}]], 
  GridLines -> {Range[-6, 6, 1], Range[-6, 6, 1]}, 
  Ticks -> {Range[-6, 6, 1], Range[-6, 6, 1]}] /. Line -> Arrow

or

ClearAll[f];
f[x_] = (1 + x^2)/(-4 + x^2);
Plot[f[x], {x, -6, 6}, 
  PlotStyle -> 
   Directive[RGBColor[1, 0, 0], AbsoluteThickness[2.25], 
    Arrowheads[{-.05, .05}]], 
  GridLines -> {Range[-6, 6, 1], Range[-6, 6, 1]}, 
  Ticks -> {Range[-6, 6, 1], Range[-6, 6, 1]}] /. Line -> Arrow
POSTED BY: Michael Rogers
Answer
21 days ago

Thank you very much friends Gianluca Gorni and Michael Rogers, your sugestions worked quite well.

Answer
20 days ago

Group Abstract Group Abstract