0
$\begingroup$

I am trying to solve the following problem in Mathematica. However, the problem is that R0 is an equation itself, an integral, to be more specific. So I always get the above error message.

An alternative how to solve this would be to assume an exogenous value for R0, say R0=1, and then write a loop that calculates R0 after each iteration and computes until convergence is reached. But I think there must be a more elegant solution to this.

\[Alpha]h = 0.2; \[Alpha]z = 0.2; \[Gamma] = 0.5; ph = 0.01; pf = \
0.1; FC = 0.1; tC = 0; TC = 0; w = 1;
\[Rho] = 0.2; \[Sigma] = 1/(1 - \[Rho]); L = 1; RA = 0.25;
G = 1; S = 1;
R0 = NIntegrate[RC[s] - RA, {s, 0, S}];
eq1 = P'[s] == -((\[Alpha]h/\[Alpha]z)^(-(\[Rho]/\[Sigma])) + (RC[s] +
          ph)^(-(\[Rho]/\[Sigma])) )/((RC[s] + ph)^-\[Sigma]   (w + 
        G + R0/L - (pf + tC) s - FC - TC));
V = \[Alpha]h ((RC[s] + 
        ph)^(-(\[Rho]/\[Sigma]))  + (\[Alpha]h/\[Alpha]z)^(-(\[Rho]/\
\[Sigma])))^((
    1 - \[Rho])/\[Rho]) (w + G + R0/L - (pf + tC) s - FC - 
      TC) - \[Gamma]  P[s] ; 
eq2 = D[V, s] == 0;
rc = NDSolveValue[{eq1, eq2, P[S] == 0, RC[S] == RA}, RC, {s, 0, S}];
Plot[rc[s], {s, 0, S}, AxesLabel -> {s, "bid rent curve"}]

Maybe the problem is that I specify R0 with NIntegrate but it does not numerically integrate at that point? But I don't know what else to do.

$\endgroup$
2
$\begingroup$

Try

Clear[R0]
rc = ParametricNDSolveValue[{eq1, eq2, P[S] == 0, RC[S] == RA},RC, {s, 0, S}, R0] 

The solution rc depends on R0!

Now you have to calculate R0 to fit your constraint

FindRoot[NIntegrate[rc[R0][s] - RA, {s, 0, S}] == R0 , {R0, 1}]
(*{R0 -> 0.0157896}*)

That's it!

$\endgroup$
  • $\begingroup$ Thank you very much! That works and makes a lot of sense. I wasn't aware of ParemetricNDSolveValue. Really grateful for your advice! I still get an error message though that the integrand has evaluated to non-numerical values for all sampling points in the region with boundaries. But the result is correct - I checked it with the loop that I proposed. $\endgroup$ – Wolfgang H. Dec 18 '18 at 14:21

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.