# NDSolve error: Cannot solve to find an explicit formula for the derivatives. Consider using the option Method->{“EquationSimplification”->“Residual”}

I get the above error message when running the following code:

αh = 0.2; αz = 0.2; γ = 0.5; ph = 0.01;
pf = 0.1; pE = 0.05; FC = 0.1; FE = 0.15; tC = 0.01; tE = 0; TC = 0.05;
TE = -0.05; w = 1; ρ = 0.2; σ = 1/(1 - ρ); L = 1; RA = 0.25; μ = 1;
G = 1; R0 = 0.1; S = 1;

v[s_] := μ Log[
Exp[(αh ((RC[s] +
ph)^(-(ρ/σ))  + (αh/αz)^(-(ρ/σ)))^((
1 - ρ)/ρ) (w + G + R0/L - (pf + tC) s - FC -
TC) - γ  Integrate[
LogisticSigmoid[
x] ((αh/αz)^(-(ρ/σ)) + (RC[x] +
ph)^(-(ρ/σ)) )/((RC[x] +
ph)^-σ   (w + G + R0/L - (pf + tC) x - FC -
TC)), {x, s, S}])/μ] +
Exp[(αh ((RC[s] +
ph)^(-(ρ/σ))  + (αh/αz)^(-(ρ/σ)))^((
1 - ρ)/ρ) (w + G + R0/L - (pE + tE) s - FE -
TE) - γ  Integrate[(1 -
LogisticSigmoid[
x]) ((αh/αz)^(-(ρ/σ)) + (RC[
x] + ph)^(-(ρ/σ)) )/((RC[x] +
ph)^-σ   (w + G + R0/L - (pf + tC) x - FC -
TC)), {x, s, S}])/μ]];

sol = FullSimplify[Solve[{D[v[s], s] == 0}, RC'[s]]]
solprime = Equal @@@ Flatten[sol];
solND = NDSolve[{solprime[[1]], RC[S] == RA}, RC, {s, 0, S}]


I have tried to add the proposed method and also Method->{"EquationSimplification"->"Solve"} but got other error messages then after quite some time of computation. Either "NDSolve::idelay: Initial history needs to be specified for all variables for delay-differential equations." or "StringForm::sfr: Item 2 requested in "Delayed time 1 = 2 computed at 3 = 4 did not evaluate to a real number." out of range; 1 items available."

Any advice would be highly appreciated. Thanks!

• Because you're integrating RC[x], from s to S = 1, it looks like a DDE. Try replacing the integral by integral'[s] == -integrand, integral[S] == 0 (and making the other changes this entails). – Michael E2 Dec 15 '18 at 13:59

As Michael E2 advised we replace the integrals with differential equations, then we get a system of three equations

\[Alpha]h = 0.2; \[Alpha]z = 0.2; \[Gamma] = 0.5; ph = 0.01;
pf = 0.1; pE = 0.05; FC = 0.1; FE = 0.15; tC = 0.01; tE = 0; TC = 0.05;
TE = -0.05; w = 1; \[Rho] = 0.2; \[Sigma] =
1/(1 - \[Rho]); L = 1; RA = 0.25; \[Mu] = 1;
G = 1; R0 = 0.1; S = 1;
eq1 = g'[s] == -LogisticSigmoid[
x] ((\[Alpha]h/\[Alpha]z)^(-(\[Rho]/\[Sigma])) + (RC[x] +
ph)^(-(\[Rho]/\[Sigma])))/((RC[x] + ph)^-\[Sigma] (w + G +
R0/L - (pf + tC) x - FC - TC)) /. x -> s;
eq2 = h'[s] == -(1 -
LogisticSigmoid[
x]) ((\[Alpha]h/\[Alpha]z)^(-(\[Rho]/\[Sigma])) + (RC[x] +
ph)^(-(\[Rho]/\[Sigma])))/((RC[x] + ph)^-\[Sigma] (w + G +
R0/L - (pf + tC) x - FC - TC)) /. x -> s;
v = \[Mu] Log[
Exp[(\[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] g[s])/\[Mu]] +
Exp[(\[Alpha]h ((RC[s] +
ph)^(-(\[Rho]/\[Sigma])) + (\[Alpha]h/\[Alpha]z)^(-(\
\[Rho]/\[Sigma])))^((1 - \[Rho])/\[Rho]) (w + G + R0/L - (pE + tE) s -
FE - TE) - \[Gamma] h[s])/\[Mu]]];
eq3 = D[v, s] == 0;

rc = NDSolveValue[{eq1, eq2, eq3, g[S] == 0, h[S] == 0, RC[S] == RA},
RC, {s, 0, S}]
Plot[rc[s], {s, 0, S}, AxesLabel -> {"s", "RC"}]


• Thanks so much, Alex Trounev and @Michael E2. Really grateful for your help! – Wolfgang H. Dec 18 '18 at 11:52
• @WolfgangH. You're welcome! – Alex Trounev Dec 18 '18 at 12:58