# Problem with ParametricNDSolve and FindMaximum [closed]

I have a system 4 coupled differential equations:

a = a1 + g (1 - Cos[(2 Pi z)/h]); k = 96.29333; b1 =
Sqrt[k^2 - (Pi/a)^2]; b2 =
Sqrt[k^2 - (3 Pi/a)^2]; Z1 = (w c)/b1; Z2 = (w c)/b2; s = 3.5 h; c =
1.257 10^-6; w = 2.8888 10^10;
With[{a = a1 + g (1 - Cos[(2 Pi z)/h]), k = 96.29333,
b1 = Sqrt[k^2 - (Pi/a)^2], b2 = Sqrt[k^2 - (3 Pi/a)^2],
Z1 = (w c)/b1, Z2 = (w c)/b2, s = 3.5 h, c = 1.257 10^-6,
w = 2.8888 10^10},
sol = ParametricNDSolve[{x'[z] == -I b1 x[z] -
0.5 D[Log[Z1], z] y[z] +
0.375 (D[Log[a], z]) ((b1 + b2)/(Sqrt[b1 b2])) u[z] +
0.375 (D[Log[a], z]) ((b1 - b2)/(Sqrt[b1 b2])) v[z],
y'[z] ==
I b1 y[z] - 0.5 D[Log[Z1], z] x[z] +
0.375 (D[Log[a], z]) ((b1 + b2)/(Sqrt[b1 b2])) v[z] +
0.375 (D[Log[a], z]) ((b1 - b2)/(Sqrt[b1 b2])) u[z],
u'[z] == -I b2 u[z] - 0.5 D[Log[Z2], z] v[z] -
0.375 (D[Log[a], z]) ((b1 + b2)/(Sqrt[b1 b2])) x[z] +
0.375 (D[Log[a], z]) ((b1 - b2)/(Sqrt[b1 b2])) y[z],
v'[z] ==
I b2 v[z] - 0.5 D[Log[Z2], z] u[z] -
0.375 (D[Log[a], z]) ((b1 + b2)/(Sqrt[b1 b2])) y[z] +
0.375 (D[Log[a], z]) ((b1 - b2)/(Sqrt[b1 b2])) x[z], x[0] == 1,
y[s] == 0, u[0] == 0, v[s] == 0}, {x, y, u, v}, {z, .1, 1}, {a1,
g, h}]]


When I run this,I got the solution as:

{x->ParametricFunction[<>],y->ParametricFunction[<>],u->ParametricFunction[<>],v->ParametricFunction[<>]}


I then run a code to maximize the function with conditions as:

F = x /. First@sol; G = u /. Extract[sol, {3}]; K =
y /. Extract[sol, {2}]; L = v /. Last@sol;
FindMaximum[{(G[a1, g, h][
z] G[a1, g, h][z]\[Conjugate])/(F[a1, g, h][
z] F[a1, g, h][z]\[Conjugate] +
G[a1, g, h][z] G[a1, g, h][z]\[Conjugate] +
K[a1, g, h][z] K[a1, g, h][z]\[Conjugate] +
L[a1, g, h][z] L[a1, g, h][z]\[Conjugate]), 0.098 <= a1 <= 0.104,
0.016 <= g <= 0.024, 0.14 <= h <= 0.16, 0.1 <= z <= 0.6}, {a1, g,
h, z}]


But, I got some errors:

ParametricNDSolve::ndsv: Cannot find starting value for the variable v. >>
ParametricNDSolve::ndsv: Cannot find starting value for the variable v. >>
ParametricNDSolve::ndsv: Cannot find starting value for the variable v. >>
General::stop: Further output of ParametricNDSolve::ndsv will be suppressed during this calculation. >>


Please help me to resolve this....There is no problem if the parameter s is some number.But the problem comes when s=3.5*h.

## closed as off-topic by MarcoB, user9660, Jens, Öskå, Mr.Wizard♦Jun 15 '16 at 11:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Community, Jens, Öskå, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

• Looking at it I would say it cannot work since you define say aas a constant by With depending upon a1 as a parameter that is then solved for. A start would be making the definition for aand other values by using SetDelayed. – gwr Jun 1 '16 at 13:35