How can one do this:
Manipulate[
Plot[ -Log[
1 - s x + (s^2 x^2)/2 - ((4 c - 4 s^2 + s^4) x^3)/(
4 (-3 + 2 s)) + (s (8 c - 8 s^2 + 3 s^3) x^4)/(8 (-3 + 2 s)) - (
s (8 c - 8 s^2 + 3 s^3) x^5)/(20 (-3 + 2 s)) ], {x, -2,
2} ], {c, 0.01, 0.2}, {s, 0.1, 1.5}]
(which works fine) without explicitly having the expression in the manipulate statement. It is not obvious from the link so I fail to see how this is a duplicate.
For example, why doesn't this work?
rule = { z -> -Log[
1 - s x + (s^2 x^2)/2 - ((4 c - 4 s^2 + s^4) x^3)/(
4 (-3 + 2 s)) + (s (8 c - 8 s^2 + 3 s^3) x^4)/(
8 (-3 + 2 s)) - (s (8 c - 8 s^2 + 3 s^3) x^5)/(
20 (-3 + 2 s))] };
Manipulate[
Plot[z /. rule, {x, 0, 10}],
{c, 0.1, 0.5},
{s, 0.1, 0.4}
]
I'd like to know what to do if
i) I have a function f[x,c,s] . This is what I've tried:
f[x_, s_,
c_ ] = -Log[
1 - s x + (s^2 x^2)/2 - ((4 c - 4 s^2 + s^4) x^3)/(
4 (-3 + 2 s)) + (s (8 c - 8 s^2 + 3 s^3) x^4)/(8 (-3 + 2 s)) - (
s (8 c - 8 s^2 + 3 s^3) x^5)/(20 (-3 + 2 s))]
Manipulate[ Plot[ f[x, c, s], {x, -2, 2} ],
{c, 0.1, 0.3},
{s, 0.1, 0.5}
]
ii) I have an expression in x, c,s
f[x,c,s]asPlots first argument. All the necessary variables are visible toManipulatethen and it it should just work as explained in Karsetn's link. – Sjoerd C. de Vries Dec 17 '14 at 20:34g[x_, s_, c_] = z /. ruleoutsize of the manipulate or with itsInitializationoption and useg[x, c, s]in the plot. – Sjoerd C. de Vries Dec 17 '14 at 20:47With[{rule = rule}, Manipulate[Plot[z /. rule, {x, 0, 10}], {c, 0.1, 0.5}, {s, 0.1, 0.4}] ], as shown in the possible duplicate. – Karsten7 Dec 17 '14 at 21:16