Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Let

f[x_]=9x^2-2x-3;

I want to make a table of f at x ={-1, -0.5, 0, 0.5, 1, 1.5, 2}. Plot these values with ListPlot + option Joined set to True Make a "normal" plot of f on the interval [-1, 2]


Table[{f[x]}, {x, -1, 2, 0.5}]

Curves := Riffle[Table[{f[x]}, {x, -1, 2, 0.5}], Table[{f[x]}, {x, -1, 2, 0.5}]]
ListLinePlot[Curves]
Plot[f[x], {x, -1, 2}]

Is this ok for this task? Because i think with Joined the points dont get joined but are still separate, but I don't know if that's normal because of ListPlot. And with Plot I don't think I got the right function, but if I do:

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

then I miss the points $-.5, .5, 1.5$. Or shouldn't that be a problem since the question is not that specific?

Thanks in advance!

share|improve this question
    
Is this what you want to do? f[x_] = 9 x^2 - 2 x - 3; Curves = Table[{x, f[x]}, {x, -1, 2, 0.5}]; ListLinePlot[Curves, InterpolationOrder -> 3] Plot[f[x], {x, -1, 2}] –  chris Oct 6 '12 at 13:05
    
Yes i think it is. –  Jaimy Oct 6 '12 at 13:08
    
But the next question was: describe the difference of the plots, where i expected listlineplot to be less accurate –  Jaimy Oct 6 '12 at 13:08
    
remove the InterpolationOrder->3 and it will be so. Interpolation was done precisely to make it look smooth! –  chris Oct 6 '12 at 13:11
    
ok thanks shouldve come up with that myself... –  Jaimy Oct 6 '12 at 13:12
show 2 more comments

1 Answer 1

It seems you want to do something like this:

f[x_] = 9 x^2 - 2 x - 3; 
 Curves = Table[{x, f[x]}, {x, -1, 2, 0.5}]; 
 Show[{
     ListLinePlot[Curves, PlotStyle -> Red, 
     Epilog -> {AbsolutePointSize[Large], Point /@ Curves}] , 
 Plot[f[x], {x, -1, 2}, PlotStyle -> Dashed]
 }]

plot versus list lineplot

which shows the difference between the Built in Plot and ListLinePlot routines.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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