0
$\begingroup$

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]
$\endgroup$
  • $\begingroup$ You should strive to use exact numbers such as 1/2 rather than floating point numbers such as 0.5. $\endgroup$ – george2079 Feb 11 '16 at 18:36
  • $\begingroup$ 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. $\endgroup$ – march Feb 11 '16 at 19:00
  • $\begingroup$ 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] $\endgroup$ – Ela Feb 11 '16 at 21:17
  • 1
    $\begingroup$ 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. $\endgroup$ – march Feb 12 '16 at 6:31
  • 1
    $\begingroup$ Please post your code as an edit to question. Also, supply definitions for Pind and Pikd. $\endgroup$ – m_goldberg Feb 12 '16 at 9:26
3
$\begingroup$

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}]

enter image description here

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]

enter image description here

note that no solutions emerge with k<0.0001.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Ela Feb 15 '16 at 17:25
  • $\begingroup$ Your function is so oscillatory that may be an intractable task. Whats the region of interest? $\endgroup$ – george2079 Feb 16 '16 at 15:51
  • $\begingroup$ Its about refractive index of some material. The unknowns are the real and imaginary part of that. $\endgroup$ – Ela Feb 16 '16 at 15:54
  • $\begingroup$ The unknowns are the real and imaginary part of that. I am looking to find 1.4<n<2 and 0<k<0.0001 $\endgroup$ – Ela Feb 16 '16 at 18:53
  • $\begingroup$ see edit, i don't think you have any solutions in that range. $\endgroup$ – george2079 Feb 16 '16 at 19:20

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.