# 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. – george2079 Feb 11 '16 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. – march Feb 11 '16 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 Feb 11 '16 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. – march Feb 12 '16 at 6:31
• Please post your code as an edit to question. Also, supply definitions for Pind and Pikd. – m_goldberg Feb 12 '16 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 Feb 15 '16 at 17:25
• Your function is so oscillatory that may be an intractable task. Whats the region of interest? – george2079 Feb 16 '16 at 15:51
• Its about refractive index of some material. The unknowns are the real and imaginary part of that. – Ela Feb 16 '16 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 Feb 16 '16 at 18:53
• see edit, i don't think you have any solutions in that range. – george2079 Feb 16 '16 at 19:20
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.33664634823799133, "perplexity": 2978.5036031160857}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-40/segments/1600401614309.85/warc/CC-MAIN-20200928202758-20200928232758-00171.warc.gz"}