3
$\begingroup$

I try to solve a list of equation in a following way but it Mathematica solves equations after 30-40 minutes or don't solve them at all. The functions that I use are ;

u[c_] := (c^(1 - σ) - 1)/(1 - σ)
k[m_] := m^α

The equation that I try to solve numerically is ;

r[m_, s_] :=  pricemit - u'[(χ s + k[m])/β] k'[m]

with the calibration

paramFinal1 = {σ -> 2.1, β -> 0.8, pricemit -> 0.0005, α -> 0.5, χ -> 0.025};

I proceeded in the following two ways but none of them worked ;

sol[i_] := Solve[r[m, i] == 0 /. paramFinal1, m]
Table[sol[i], {i, 1, 15}]

The second way I have tried did not work neither ;

sol11 = Table[r[m, i] /. paramFinal1, {i, 1, 10}]
sol12 = Solve[sol11==0 /.paramFinal1]

These two operations take so much time or put Mathematica on "Running..." status.

How can I express this operations that Mathematica could handle easily ? Any hints, suggestions are appreciated. Thanks in advance.

Edit : When I solve according to $s$ instead of $m$, the system is solved easily but I try to list the corresponding $m$ values for $s$ on a range between 0 and 15 (or some other number instead of 15)

$\endgroup$
4
$\begingroup$

Perhaps you want this

u[c_] := (c^(1 - σ) - 1)/(1 - σ)
k[m_] := m^α
r[m_, s_] := pricemit - (D[u[c], c] /. c -> (χ s + k[m])/β) D [k[m], m]
paramFinal1 = {σ -> 2.1, β -> 0.8,  pricemit -> 0.0005, α -> 0.5, χ -> 0.025};
sol[i_] := FindRoot[r[m, i] == 0 /. paramFinal1, {m, 1}]
Table[sol[i], {i, 15}]

(*
{{m -> 63.437},  {m -> 63.1679}, {m -> 62.8997}, {m -> 62.6323}, 
 {m -> 62.3657}, {m -> 62.1},    {m -> 61.8351}, {m -> 61.5711},
 {m -> 61.3079}, {m -> 61.0456}, {m -> 60.7841}, {m -> 60.5234}, 
 {m -> 60.2635}, {m -> 60.0045}, {m -> 59.7463}}
*)
$\endgroup$
  • $\begingroup$ this is impressive. Thanks a lot. I would like to know why the code works perfectly when you write in this way the first derivatives of these functions. $\endgroup$ – optimal control Dec 23 '15 at 19:08
  • $\begingroup$ @optimalcontrol I wrote them that way for clarity. Try r[m_, s_] := pricemit - u'[(\[Chi] s + k[m])/\[Beta]] k'[m] $\endgroup$ – Dr. belisarius Dec 23 '15 at 19:22
  • $\begingroup$ You can use your equations as is (although repetitively evaluating the derivative seems inefficient). I believe the key to belisarius's answer is the use of FindRoot. $\endgroup$ – Jack LaVigne Dec 24 '15 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.