# DSolve wont solve

I have the following code to solve wave equations, but Dsolve doesnt give me anything, I would like to know why.

n1 = 0.018;
n2 = 0.018;
n3 = 0.018;
n4 = 0.026;
n5 = 0.026;
\[Epsilon]1 = 0;
\[Epsilon]2 = 0;
\[Epsilon]3 = 0;
\[Epsilon]4 = 0.0165;
\[Epsilon]5 = -0.0165;
\[CapitalLambda]1 = 0.498;
\[CapitalLambda]2 = 0.5;
\[CapitalLambda]3 = 0.502;
\[CapitalLambda]4 = 0.498;
\[CapitalLambda]5 = 0.502;

lg = 100*10^(-6);

k1 = 2*Pi*(2*1.55/\[Lambda] - (1 + \[Epsilon]1*(z/
lg))/\[CapitalLambda]1);
k2 = 2*Pi*(2*1.55/\[Lambda] - (1 + \[Epsilon]2*(z/
lg))/\[CapitalLambda]2);
k3 = 2*Pi*(2*1.55/\[Lambda] - (1 + \[Epsilon]3*(z/
lg))/\[CapitalLambda]3);
k4 = 2*Pi*(2*1.55/\[Lambda] - (1 + \[Epsilon]4*(z/
lg))/\[CapitalLambda]4);
k5 = 2*Pi*(2*1.55/\[Lambda] - (1 + \[Epsilon]5*(z/
lg))/\[CapitalLambda]5);

eq1 = -I*Pi/\[Lambda]*(n1*Exp[-I*(k1*z)] + n2*Exp[-I*(k2*z)] +
n3*Exp[-I*(k3*z)] + n4*Exp[-I*(k4*z)] + n5*Exp[-I*(k5*z)])
eq2 = I*Pi/\[Lambda]*(n1*Exp[I*(k1*z)] + n2*Exp[I*(k2*z)] +
n3*Exp[I*(k3*z)] + n4*Exp[I*(k4*z)] + n5*Exp[I*(k5*z)])

DSolve[{a'[z] == eq1*b[z], b'[z] == eq2*a[z], a[0] == 1,
b[lg] == 0}, {a[z], b[z]}, z]


Dsolve doesnt give me solution nor error. I would like to know why. thanks.

• Generally, if Mma returns the same expression it means that Mma cannot find the solution. If it does not return anything at all, I guess that it stays calculating. You will see that its right margin bracket will be selected. From your description, it looks like the latter case. You are solving linear equations with z-dependent coefficients. Moreover, each coefficient contains periodic terms with incommensurate periodicities. It is not obvious that these equations can be solved in terms of analytic or special functions (such as the Mathieu functions). Jan 11 at 8:51
• Continuation What I would do first of all is to let Mma work on it for a longer time. There is a small chance that it will finally find the solution. Let me recommend you defining eq1,2 as the functions of z, like this: eq1[z_] := -I*Pi/\[Lambda]*(n1*Exp[-I*(k1*z)] + n2*Exp[-I*(k2*z)] +n3*Exp[-I*(k3*z)] + n4*Exp[-I*(k4*z)] + n5*Exp[-I*(k5*z)]). If after an hour or so, Mma still returns nothing, try NDSolve. Jan 11 at 8:51

These do not seem to be solvable analytically. Giving a numerical values to λ now DSolve gives errors on console

PolynomialGCD::lrgexp: Exponent is out of bounds for function PolynomialGCD.


You can try ParametricNDSolve where λ is the parameter as this is the only non numerical value you have. This is as good as you can get. The solutions are also complex. And try to avoid using real numbers with exact solver. Better to stick to exact numbers. Here it did not make a difference, but sometimes it can affect the exact solver when using non exact numbers.

n1 = 18/1000;
n2 = 18/1000;
n3 = 18/1000;
n4 = 26/1000;
n5 = 26/1000;
ϵ1 = 0;
ϵ2 = 0;
ϵ3 = 0;
ϵ4 = 165/10000;
ϵ5 = -165/10000;
Λ1 = 498/1000;
Λ2 = 1/2;
Λ3 = 502/1000;
Λ4 = 498/1000;
Λ5 = 502/1000;

lg = 100*10^(-6);

k1 = 2*Pi*(2*155/100/λ - (1 + ϵ1*(z/lg))/Λ1);
k2 = 2*Pi*(2*155/100/λ - (1 + ϵ2*(z/lg))/Λ2);
k3 = 2*Pi*(2*155/100/λ - (1 + ϵ3*(z/lg))/Λ3);
k4 = 2*Pi*(2*155/100/λ - (1 + ϵ4*(z/lg))/Λ4);
k5 = 2*Pi*(2*155/100/λ - (1 + ϵ5*(z/lg))/Λ5);

eq1=-I*Pi/λ*(n1*Exp[-I*(k1*z)]+n2*Exp[-I*(k2*z)]+n3*Exp[-I*(k3*z)]+n4*Exp[-I*(k4*z)]+n5*Exp[-I*(k5*z)])
eq2=I*Pi/λ*(n1*Exp[I*(k1*z)]+n2*Exp[I*(k2*z)]+n3*Exp[I*(k3*z)]+n4*Exp[I*(k4*z)]+n5*Exp[I*(k5*z)])

ode1 = a'[z] == eq1*b[z]
ode2 = b'[z] == eq2*a[z]
ic = {a[0] == 1, b[lg] == 0}

sol = ParametricNDSolve[{ode1, ode2, ic}, {a, b}, {z, 0, 1}, {λ}]


Since solutions are complex, you can plot the real or imaginary parts

Plot[Re@Evaluate[a[10][z] /. sol], {z, 0, 1}]


Plot[Im@Evaluate[a[10][z] /. sol], {z, 0, 1}]


Same for b

• Thanks! at the end where you plot, Is 10 the value of λ? Jan 12 at 0:23
• @raeddis yes. In the call Evaluate[a[10][z] the 10 is lambda. you can change it to any other value to see the effect. Use Manipulate to make it easier to do if needed. You only need to solve the equations once, since lambda is a parameter. Jan 12 at 4:34