Message Boards Message Boards

GROUPS:
1000 Views
|
3 Replies
|
6 Total Likes
|

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:
3 Replies

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

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

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

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract