# Help on using Solve

I tried to use Solve to solve a set of nonlinear equations and got this error:

Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help.

Has anyone encountered this problem before? I am new to Mathematica and don't know how to fix it.

d = 0.02;
l = 1.5*10^(-4);
a = Exp[-2*Pi*k*d/l];
c = 4*Pi*n*d/l;
R = ((n - 1)^2 + k^2)/((n + 1)^2 + k^2);
Solve[{(a^2*(1 - R)^2)/(1 - 2*a^2*R*Cos[c] + a^4*R^2) == 0.56,
R (1 + a^4 - 2*a^2*Cos[c])/(1 - 2*a^2*R*Cos[c] + a^4*R^2) == 0.06},
{n, k}, Reals]

• You should strive to use exact numbers such as 1/2 rather than floating point numbers such as 0.5. Commented Feb 11, 2016 at 18:36
• Please provide your code. (Edit your post by clicking the grey edit button below your post; for formatting help, click the grey question mark at the right of the editing toolbar.) It will make the problem easier to diagnose. In addition, provide more details about the output. Did Solve actually return a solution? Did it return unevaluated? Solve is mainly useful for polynomial equations and other relatively simple equations for which there are closed forms. If Solve doesn't work, you can always try Reduce, NSolve, or FindRoot. Commented Feb 11, 2016 at 19:00
• Thanks for your comment. I edited my question. Solve just showed me my equation without any answer and the error I posted earlier. My equations are complicated and I tried NSolve and Reduce as well. i have copied my code below:d = 0.02; l = 1.5*10^(-4); a = Exp[-2*Pikd/l]; c = 4*Pind/l; R = ((n - 1)^2 + k^2)/((n + 1)^2 + k^2); Solve[{(a^2*(1 - R)^2)/(1 - 2*a^2*RCos[c] + a^4*R^2) == 0.56, R (1 + a^4 - 2*a^2*Cos[c])/(1 - 2*a^2*RCos[c] + a^4*R^2) == 0.06}, {n, k}, Reals]
– Ela
Commented Feb 11, 2016 at 21:17
• I recommend using FindRoot, because your functions are complicated enough that numerical solutions are required. However, the way that you've defined your parameters makes the functions numerically intractable, given that there are exponentials that look like Exp[-3000 k] that vary a lot with changes in k. I recommend re-scaling your variables to make this nicer. Commented Feb 12, 2016 at 6:31
• Please post your code as an edit to question. Also, supply definitions for Pind and Pikd. Commented Feb 12, 2016 at 9:26

This has to be done numerically, and I suspect with manual input. First visualize the solutions:

ContourPlot[{R (1 + a^4 - 2*a^2*Cos[c])/(1 - 2*a^2*R*Cos[c] +
a^4*R^2) == 0.06,
(a^2*(1 - R)^2)/(1 - 2*a^2*R*Cos[c] + a^4*R^2) == 0.56}, {n, 0,
5}, {k, -0.001, .001}]


Then FindRoot works well given good starting points

FindRoot[{R (1 + a^4 - 2*a^2*Cos[c])/(1 - 2*a^2*R*Cos[c] + a^4*R^2) ==
0.06,
(a^2*(1 - R)^2)/(1 - 2*a^2*R*Cos[c] + a^4*R^2) ==
0.56}, {n, .5}, {k, .0005}]
FindRoot[{R (1 + a^4 - 2*a^2*Cos[c])/(1 - 2*a^2*R*Cos[c] + a^4*R^2) ==
0.06,
(a^2*(1 - R)^2)/(1 - 2*a^2*R*Cos[c] + a^4*R^2) == 0.56}, {n,
2.5}, {k, .0005}]


{n -> 0.498296, k -> 0.00026622}

{n -> 2.50154, k -> 0.000239228}

Edit: here is a shotgun approach to finding many solutons.

pts = Union@Table[FindRoot[{
R (1 + a^4 - 2*a^2*Cos[c])/(1 - 2*a^2*R*Cos[c] + a^4*R^2) ==
0.06,
(a^2*(1 - R)^2)/(1 - 2*a^2*R*Cos[c] + a^4*R^2) == 0.56
}, {n, RandomReal[{1.4, 2}]}, {k, RandomReal[{0, 0.0001}]}], {2000}];

ListPlot[pts]


note that no solutions emerge with k<0.0001.

• Thanks for your answer @george2079, but FindRoot just gives me one root near the chosen starting point. But I need all the solutions in some specific regions.
– Ela
Commented Feb 15, 2016 at 17:25
• Your function is so oscillatory that may be an intractable task. Whats the region of interest? Commented Feb 16, 2016 at 15:51
• Its about refractive index of some material. The unknowns are the real and imaginary part of that.
– Ela
Commented Feb 16, 2016 at 15:54
• The unknowns are the real and imaginary part of that. I am looking to find 1.4<n<2 and 0<k<0.0001
– Ela
Commented Feb 16, 2016 at 18:53
• see edit, i don't think you have any solutions in that range. Commented Feb 16, 2016 at 19:20