What does (/. % /.) mean ?

Example =>

Plot[Evaluate[x[t] /. % /. {{c -> 0.3}, {c -> 0.2}, {c -> 0.4}}], {t, 0, 5}, AxesLabel -> {t, "x(t)"}]

What does (/. % /.) mean ? I don’t understand and I can’t search it .
here is the full example :

Aya,

/. Is an in-line a Shortcut for ReplaceAll[]

% refers to the previous output

So your line replaces the solution from DSolve in for x and then replaces some individual parameters before plotting.

Regards,

Neil

Hi Aya,

Take a look at this post on MSE for a summary of many WL operators. The entire thread has a lot of useful information for beginners.

Thanks a lot!

Aya,

As a recommendation, I really dislike using % anywhere in code. It makes the code less readable and less predictable. It’s more useful for interactive use in Mathematica. If you evaluate parts of your notebook out of order, it will break.

I would have written that code by setting the solution to a variable and then define a list of cases to plot:

solution = DSolve[...]
plotcases = {{c->0.3},...}
Plot[Evaluate[x[t] /. solution /. plotcases], {t, 0, 5}, AxesLabel -> {t, "x(t)"}]

So you can see that you are plotting the x given by the solution for each of the plotcases. Now it does not matter if you go back and make a change and reevaluate anything out of order.

Regards,

Thank you so much, mister Neil!
You were so helpful twice, so thank you so much again!