# ListPlot doesn't start from the origin

I've just started using Mathematica for one my university modules, so I tried replicating the results from our practical.

I've defined a function

f[x_]:= ax - R/2 x^2


After this, if I define

ListA = Table [f[j/5] /.a -> 5 /.R -> 1/4,{j,0,75}]


And then plot it with Plot1 = ListPlot[ListA] my graph will start from 1, rather than 0 (screenshot below)

However, if I define

ListB = Table [f{j/5},f[j/5] /.a -> 5 /.R -> 1/4,{j,0,75}]


And then plot it with Plot2 = ListPlot[ListB], the graph starts from 0, as seen below

Can anyone explain to me the logic in these commands? I've tried searching for the answer both on StackExchange and in Google and couldn't find anything. I really appreciate it!

P.S. Is there any way to manually adjust the colour-coding of syntax? I've figured out that it changes to green/orange when I stop typing, but some colour-coding is different from the original code, so I am not sure what to do with it. This is my first time posting on StackExchange, so I am still figuring it out

• In definition of "f" you use "ax", but in "ListA" and "ListB" you use "a". Then, the definition of "ListB" is wrong syntax. Table take 2 arguments not 3 Jan 23 at 18:02
• Welcome to the community. Take a look at DiscretePlot. Side note, you can replace multiple items simultaneously like /. {a -> 5, R -> 1/4} Jan 23 at 18:04
• @DanielHuber I think I made a mistake of not put a space between 'a' and 'x'. I just want to define a function with a constant 'a' and a variable 'x' Jan 23 at 18:21
• There's something funny with your code, but... It is a common convention in Mathematica that if a list of numeric values (instead of lists for multi-dimensional data) is given as input to a function which expects multi-dimensional data, it is interpreted as {{1, val1}, {2, val2}, ...} by default, starting "x coordinate" from 1. In the case of ListPlot this fact is implied by the documentation definition of the first syntax form, where you can see $\{y_1,\ldots,y_n\}$ being interpreted as $\{\{i,y_i\},\ldots,\{n,y_n\}\}$ which corresponds with $\{\{1,y_1\}\},\ldots,\{n,y_n\}\}$. Mar 1 at 5:56

Clear["Global*"]

f[x_] := **a x** - R/2 x^2 ;

ListA = Table[f[j/5] /. a -> 5 /. R -> 1/4, {j, 0, 75}]

Plot1 = ListPlot[ListA]

ListB = Table[f {j/5}, f[j/5] /. a -> 5 /. R -> 1/4, {j, 0, 75}]
`
• This does not evaluate as posted. Please check for correctness and repost. Thanks.
– Syed
Jan 30 at 6:30