-6
$\begingroup$
f[x_] = Sin[x];
x0 = 0;
a = -3 π;
b = 3 π;
c = -1.3;
d = 1.3;
a0 = -10;
b0 = 10;
Needs["Graphics`Colors`"];
Cdot = Graphics[{{Red, PointSize[0.02], Point[{x0, f[x0]}]}}];
Rends = Graphics[{{Green, Line[{{a0, c}, {a0, d}}]}, {Red, 
     Line[{{x0, c}, {x0, d}}]}, {Green, Line[{{b0, c}, {b0, d}}]}}];
For[n = 2, n <= 5, n++,
 P[x_] = Normal[Series[f[x], {x, x0, 2 n + 1}]];
 graph = Plot[{f[x], P[x]}, {x, a, b}, PlotStyle -> {Magenta, Blue}, 
   PlotRange -> {{a, b}, {c, d}}, 
   Ticks -> {Range[-3 π, 3 π, π], Range[-0.5, 1, 0.5]},
   DisplayFunction -> Identity];
 Show[graph, Cdot, Rends, 
  DisplayFunction -> $DisplayFunction];
 Print["f[x] = ", f[x], "\n", "P[x] = ", P[x]];]

When I evaluate the above code, I get the following message.

Get::noopen: Cannot open Graphics`Colors`. >>

What is wrong with this code? Please help me.

$\endgroup$
3
  • $\begingroup$ Your syntax appears to have a bunch of errors in it. Also, you provide no context of what you're trying to do, where your code came from, what version of Mathematica the code was written under, and what version of Mathematica you are operating with, which is hardly conducive to getting responses. $\endgroup$ – DumpsterDoofus Dec 25 '13 at 1:08
  • 1
    $\begingroup$ The "Graphics`Colors`" package from V5 has been replaced by ColorData in V6 and later (and it works differently). I believe all the colors I see in your code are now available without loading anything. We also don't usually need to bother with DisplayFunction. It looks like you're using old code on a newer Mathematica. $\endgroup$ – Michael E2 Dec 25 '13 at 1:16
  • 1
    $\begingroup$ Also, please learn to format your questions. Code blocks should be indented four spaces, which you can do by selecting it and clicking the {} button above the edit box. There is more help on formatting available through the ? button. $\endgroup$ – Michael E2 Dec 25 '13 at 1:19
4
$\begingroup$

In a better Mathematica style:

f[x_] := Sin[x]
x0 = 0; b = 3 π; d = 1.3; b0 = 10;
epilog = {
   {Green, Line[{{-b0, -d}, {-b0, d}}], Line[{{b0, -d}, {b0, d}}]},
   {Red, Line[{{x0, -d}, {x0, d}}]},
   {Red, PointSize[0.02], Point[{x0, f[x0]}]}};

GraphicsGrid[Partition[
  Plot[{f[x], #}, {x, -b, b},
       PlotStyle -> {Magenta, Blue}, PlotRange -> {{-b, b}, {-d, d}},
       PlotRangePadding -> 1, Ticks -> {Range[-b, b, b/3], Range[-0.5, 1, 0.5]},
       Epilog -> epilog, PlotLabel -> Style[#, 9, Background -> LightBlue]] &@
     Normal[Series[f[x], {x, x0, 2 # + 1}]] & /@ Range[2, 5],
  2], Frame -> All]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ @Mr.Wizard Yeah, sometimes I feel like that. Ho Ho Ho! $\endgroup$ – Dr. belisarius Dec 25 '13 at 17:34

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