# Manipulate and Initialization with functions and some variables

I am trying to do a manipulate with a function that depends on several variables, some of which are also functions. I can't get it to work. I have tried including an "Initialization" but it only accepts a function with a single variable. For example, if I build the following manipulate, it works:

However, if A now depends on two variables, "v" and "q", then it doesn't work.

How could I do it? Thank you very much for your help.

• Please post actual, copyable input code instead of images of code! Dec 24, 2021 at 17:21

Try:

a = 2 v q;

Manipulate[Plot[f[v, q], {x, 14, 17}],
{{v, 1}, 0.5, 9, 0.1}, {{q, 1}, 1, 15, 0.1},
Initialization :> {f[v_, q_] = a x}]


Or simpler:

Manipulate[
a = 2 v q;
Plot[a x, {x, 14, 17}],
{{v, 1}, 0.5, 9, 0.1}, {{q, 1}, 1, 15, 0.1}]

• Thank you very much Daniel. And if now for example q were a function of another variable, in initizalitazion I should put all the variables.
– Manu
Mar 29, 2021 at 9:42
• Can you make an example? Mar 29, 2021 at 9:48
• Now, v and q are functions of b and c, respectivelly. a = 2 v q; v = 3 + b q = 2 c; Manipulate[ Plot[f[b, c], {x, 14, 17}], {{b, 1}, 0.5, 9, 0.1}, {{c, 1}, 1, 15, 0.1}, Initialization :> {f[c_, b_] = a*x}]
– Manu
Mar 29, 2021 at 9:54
• 3 + b q = 2 c; is a syntax error. Do you mean: v= 2 c ? Further, if "v and q are functions of b and c" you should specify: v=.., c=.. Mar 29, 2021 at 10:52
• Sorry, I want write that a = 2 vq; v = 3 + b; q = 2 c; a is a function of v and q. On the other hand, v is function of b and q is function of c. I have probe the code that I indicated you before and it work.
– Manu
Mar 29, 2021 at 11:04