Group Abstract Group Abstract

Message Boards Message Boards

Manipulate[ FindRoot[..] ... ]

who can help me to improve this algorithm and extract values Manipulate[] for reuse

X = (H (\[Delta]/Pn)^\[Delta])^(1/(
 1 - \[Delta])); Nx =  \[Delta]/Pn X; Bx = (1 - \[Delta]) X ;
f[Z_] = -0.0003*(Z)^3 + 0.006*(Z)^2 - 0.1*(Z) + 1;  
K = A f[X]; Bn = Pn K; 
R = Bx + Bn; Xc = \[Alpha] R; Nc = (1 - \[Alpha])/Pn R; 
Simplify[K == Nc + Nx ] ;  (*6*)
Simplify[X1 == X];   (*7*)
Simplify[Bx1 == Bx];  (*8*)
Simplify[Bn1 == Bn]  ; (*9*)
Simplify[K1 == K] ;(*10*) 
Simplify[\[Alpha]Nx == Nx]; (*11*)
Simplify[\[Alpha]Nc == Nc];  (*12*)
Simplify[\[Alpha]Xc == Xc];  (*13*)
Manipulate[
 FindRoot[{Out[6], Out[7], Out[8], Out[9], Out[10], Out[11], Out[12], 
   Out[13]}, {{Pn, 1}, {X1, 1}, {Bx1 , 1}, {Bn1 , 1}, {K1, 
    1}, {\[Alpha]Nx, 1}, {\[Alpha]Nc, 1}, {\[Alpha]Xc, 1}}]
 , {H, 4, 5}, {M, 4, 2}, {\[Epsilon], 0.4, 2}, {\[Delta], 0.3, 
  2}, {\[Alpha], 0.5, 1}, {A, 20, 100}]
Attachments:
POSTED BY: Harvey Vargas
7 Replies

You have defined x to be a function of Pn only, but in fact, it is dependent on several other parameters and you are not passing those values into the function. So, they are global. But inside Manipulate, they are local control variables. One way to address this is to make sure all of your functions pass in all of the parameter values:

x[Pn_, h_, d_] := (h (d/Pn)^d)^(1/(1 - d));

nx[Pn_, h_, d_] := d/Pn x[Pn, h, d];

Bx[Pn_, h_, d_] := (1 - d)*x[Pn, h, d];

f[z_] := -0.0003*z^3 + 0.006*z^2 - 0.1*z + 1;

n[Pn_, k_, h_, d_] := k f[x[Pn, h, d]];

Bn[Pn_, k_, h_, d_] := Pn n[Pn, k, h, d];

r[Pn_, k_, h_, d_] := Bx[Pn, h, d] + Bn[Pn, k, h, d];

xc[Pn_, a_, k_, h_, d_] := a r[Pn, k, h, d];

nc[Pn_, a_, k_, h_, d_] := (1 - a)/Pn r[Pn, k, h, d];

eq[Pn_, k_, a_, h_, d_] := 
  n[Pn, k, h, d] - nc[Pn, a, k, h, d] - nx[Pn, h, d];

Manipulate[
 FindRoot[eq[Pn, k, a, h, d] == 0, {Pn, 0.5966337871664869`}], {h, 4, 
  5}, {d, 0.3, 2}, {a, 0.5, 1}, {k, 20, 100}]
POSTED BY: Jeffrey Bryant
Posted 11 years ago
POSTED BY: Tugrul Temel

You could try to assign the outputs of the Simplify[] commands to variables, for instance out6, out7, etc. (to keep things looking the same).

thank you very much, the last thing I would like to know is if I can somehow make it show me the values of Manipulate [] as tables.

Manipulate[
 FindRoot[{eq[Pn, k, a, h, d] == 0, 
   x[Pn, h, d] == casax}, {{casax, 1}, {Pn, 0.5966337871664869}}], {h,
   4, 5}, {d, 0.3, 2}, {a, 0.5, 1}, {k, 20, 100}]
POSTED BY: Harvey Vargas

Thank you very much, and manages to incorporate variables as functions but Manipulate [] does not work me, someone can help me

x[Pn_] := (h (d/Pn)^d)^(1/(1 - d)); nx[Pn_] :=   d/Pn x[Pn]; 
Bx[Pn_] := (1 - d)*x[Pn]; f[z_] := -0.0003*z^3 + 0.006*z^2 - 0.1*z + 1;
n[Pn_] := k f[x[Pn]]; Bn[Pn_] := Pn n[Pn]; r[Pn_] := Bx[Pn] + Bn[Pn]; 
xc[Pn_] := a r[Pn] ; nc[Pn_] := (1 - a)/Pn r[Pn];
eq[Pn_] := n[Pn] - nc[Pn] - nx[Pn];
Manipulate[FindRoot[eq[Pn] == 0, {Pn, 0.5966337871664869`}], {h, 4, 5}, {d, 0.3, 2}, {a, 0.5, 1}, {k, 20, 100}]
Attachments:
POSTED BY: Harvey Vargas

the problem is that I have not managed to run me otherwise, everything works perfectly but fails to work me without using the OUT [%] also would eliminate all that and the program work without placing me Simplify[]

Thx

POSTED BY: Harvey Vargas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard