0
$\begingroup$

I have to solve a system of equations in the following way: I first guess a value for a variable, let's call it y, calculate another variable z, which is a function of y, z(y), and then check if another condition was met on z. The simplest example that slightly resembles my problem looks like this:

a = 2;
b = 3;
y = 1; (*initial guess*)
z = x /. FindRoot[a*x + Log[x] - Log[y], {x, 0.01}];
FOCy = b*y + Log[y] + Log[z] 

So I should keep doing this while FOCy is different than 0.

I usually use MATLAB for these kind of problem. There, I would discretize y on a grid and I would use a "shooting algorithm" (a fixed point using Intermediate Value Theorem). On Mathematica, I don't know what would be the recommended way to proceed.

Any thoughts?

$\endgroup$
1
$\begingroup$

Why not just include both equations in your FindRoot call:

a=2; b=3;
FindRoot[{b y+Log[y]+Log[z],a z+Log[z]-Log[y]},{{y,1},{z,1}}]

{y -> 0.57516, z -> 0.309632}

$\endgroup$
1
  • $\begingroup$ That can clearly be done in my example above, indeed, @carlwoll. I am going to check if it works in my problem and I get back to you. $\endgroup$
    – Laura K
    Sep 18 '17 at 22:06

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.