1
$\begingroup$

I try to solve a quite messy equation. Normally NSolve finds the result very easily.

I use the following code :

paramFinal = {σ -> 0.5, ρ -> 0.05, a -> 0.05, δ -> 0.00001, γ -> 0.001, ψ -> 1, h -> 100, θ -> 1, y -> 0.1, cmin -> 100, β -> 1};

The equation I try to solve is the following :

root2 = NSolve[{(1 - s) s - ((γ a)^2 (σ (1 - Exp[-(β - ρ) h]))/(β - ρ))/((a - \δ) (a - δ) - (ρ + (y - θ s))) ((-θ/(\ρ + (y - θ s)) ((((a - δ) (1 - s) s)/(γ a))^(1 - σ)/(((σ (1 - Exp[-(β - ρ) h]))/(β - ρ))^(1 - σ) (1 - σ)) - cmin ((1 - Exp[-(β - ρ) h])/(β - ρ)) - (y \- θ s) ψ ) - ψ θ)/((1 - 2 s) - (ρ + (y - θ s)))) == 0 /. paramFinal}, s]

When I give a value for $\beta$, NSolve is working but the problem starts in the second step. Normally, afterwards I try to solve the following equation

NSolve[2 s - β == 0, β]

Hovewer, my aim is to solve the second equation. Then, I remove the numerical value for $\beta$ in paramFinal. Without a numerical value for $\beta$ in code, Mathematica don't give any output for root2. (remains always in "Running..." mode. ) Since, I don't have any value for $s$, I can not find a result for $\beta$ in second equation. Is there anything that I can do to find a result for this problem ?

PS. I don't want to replace the second equation in first one. Normally, my second equation is more complex than this one but in order to ease to presentation of the question, I deleted some stages to be more concise.

$\endgroup$
  • $\begingroup$ I don't get how the two equations are connected... Do you want s in the second equation to have the value root2? $\endgroup$ – Marius Ladegård Meyer May 15 '17 at 16:36
  • $\begingroup$ @MariusLadegårdMeyer I try to find an expression (or a numerical value )for "s" from root2 and afterwards find a numerical value for $\beta$ from the second equation. $\endgroup$ – optimal control May 15 '17 at 16:38
  • $\begingroup$ Ok, if I understand correctly, the part that never finishes is the computation of root2, right? Have you tried FindRoot instead of NSolve? $\endgroup$ – Marius Ladegård Meyer May 15 '17 at 16:42
  • $\begingroup$ Does bbgodfrey's answer solve your problem? $\endgroup$ – Michael E2 May 15 '17 at 23:10
  • $\begingroup$ @MichaelE2 Since I was trying NSolve on more complex equations, NSolve did not work but I tried to solve these two equations simultaneously with FindRoot and it worked ! Thanks ! $\endgroup$ – optimal control May 16 '17 at 9:05
1
$\begingroup$

The goal appears to be to determine s and β simultaneously. This can be accomplished rapidly by

paramFinal = {σ -> 1/2, ρ -> 1/20,  -> 1/2, δ -> 10^-5, γ -> 10^-3, ψ -> 1, 
        h -> 100, θ -> 1, y -> 1/10, cmin -> 100};
root2 = NSolve[{(1 - s) s - ((γ a)^2 (σ (1 - Exp[-(β - ρ) h]))/(β - ρ))/((a - δ) (a - δ)
     - (ρ + (y - θ s))) ((-θ/(ρ + (y - θ s)) ((((a - δ) (1 - s) s)/(γ a))^(1 - σ)/
     (((σ (1 - Exp[-(β - ρ) h]))/(β - ρ))^(1 - σ) (1 - σ)) - cmin ((1 -    Exp[-(β - ρ) h])
     /(β - ρ)) - (y - θ s) ψ) - ψ θ)/((1 - 2 s) - (ρ + (y - θ s)))) == 0 /. paramFinal, 
     2 s - β == 0}, {s, β}, Reals]
(* {{s -> 0.00105548, β -> 0.00211096}, {s -> 0.149561, β -> 0.299123}, 
    {s -> 0.850115, β -> 1.70023}, {s -> 0.999902, β -> 1.9998}} *)
$\endgroup$

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.