MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Plotting

On 1/27/07 at 6:37 AM, ghcgwgwg at (Rayne) wrote:

>Hi all, I want to plot the cubic equation f(x) == x^3 - 16x^2 + 3x +
>1 == 0. I had:

>f==x^3-16 x^2+3 x+1 ==== 0 Plot[f,{x,-1,20}]

>but I was unable to get the plot.

If you have accurately posted what you tried, it should not be 
surprising Plot generates error messages.

x^3-16 x^2+3 x+1 === 0  will always evaluate to False since the 
expression x^3-16 x^2+3 x+1 is clearly not identical to 0. So, 
the expression

f==x^3-16 x^2+3 x+1 === 0

Evaluates to f==False.

Now this is an equation and does not define a value for f. So, 
when you try

Plot[f, {x, -1, 20}]

you are asking Mathematica to plot an undefined variable with no 
dependence on x. And the result is error message stating f has 
no numerical values.

Presumably you meant to define f as follows:

f = x^3-16 x^2+3 x+1 == 0

But while this does assign f a value, this is not something Plot 
will work with since

f = x^3 - 16*x^2 + 3*x + 1 == 0

x^3 - 16*x^2 + 3*x + 1 == 0

f /. x -> 2


That is f will evaluate to either True or False for any numeric 
value assigned to x.

You can of course do

Plot[x^3 - 16*x^2 + 3*x + 1, {x, -1, 20}];

Is this what you want?


roots=NSolve[f, x]

{{x -> -0.1726471308825491}, {x -> 0.3664487167738349},
   {x -> 15.806198414108714}}

That is your cubic has three real roots. So, perhaps you want a 
plot of the value of the cubic at these roots, i.e.,

ListPlot[{x /. #, x^3 - 16 x^2 + 3 x + 1 /. #}&/@roots,
          Frame->True, Axes->None, PlotStyle ->PointSize[.02]];
To reply via email subtract one hundred and four

  • Prev by Date: RE: Schlegel diagram
  • Next by Date: Re: Sequence of Bernoulli RVs
  • Previous by thread: Re: Plotting
  • Next by thread: Re: Plotting