1
$\begingroup$

I need to solve two nonlinear equations with FindRoot, as shown below.

Remove[no, ne, ne2, vo, ve, ve2, θ, λ];

no[λ_] := Sqrt[(2.7359 + 0.01878/((λ*10^-3)^2 - 0.01822) - 0.01354 (λ*10^-3)^2)];

ne[λ_] := Sqrt[(2.3753 + 0.01224/((λ*10^-3)^2 - 0.01667) - 0.01516 (λ*10^-3)^2)];

ne2[θ_, λ_] := Sqrt[ 1/((Cos[θ])^2/(no[λ])^2 + (Sin[θ])^2/(ne[λ])^2)];  

vo[λ_] = 1/(no[λ] - λ D[no[λ], λ]);

ve[λ_] = 1/(ne[λ] - λ D[ne[λ], λ]);

ve2[λ_, θ_] = 1/(ne2[λ, θ] - λ D[ne2[λ, θ], λ]);

FindRoot[
  {ne2[λ/2, θ]/(λ/2) == no[λ]/ λ + ne2[λ, θ]/λ, 
   2/ve2[λ/2, θ] == 1/vo[λ] + 1/ve2[λ, θ]}, 
  {{λ, 1514, 1000, 2000}, {θ, 0.5, 0.1, 1}}]

But I cannot obtain the correct solution, and the following warning appears:

The point {1514,0.1} is at the edge of the search region {0.1, 1.} in coordinate 2 and the computed search direction points outside the region.

My question is how to remove this warning and obtain the correct answer. Any help or comment are highly appreciated.

Update

In fact, I find it is possible to solve these two equations separately, and {1514.73, 0.502} is almost the best solution, as shown in the codes below. But I still need to solve these two nonlinear equations simultaneously.

Codes for obtaining the best $\theta$:

Remove[no, ne, ne2, vo, ve, ve2, θ, λ];

no[λ_] := Sqrt[(2.7359 + 0.01878/((λ*10^-3)^2 - 0.01822) - 0.01354 (λ*10^-3)^2);

ne[λ_] := Sqrt[(2.3753 + 0.01224/((λ*10^-3)^2 - 0.01667) - 0.01516 (λ*10^-3)^2)];

ne2[θ_, λ_] := Sqrt[ 1/((Cos[θ])^2/(no[λ])^2 + (Sin[θ])^2/(ne[λ])^2)];  

λ = 1514.73;

Solve[ne2[θ, λ/2]/(λ/2) == no[λ]/λ + ne2[θ, λ]/λ, θ]

With the above codes, I can obtain the results of 0.502.

Codes for obtaining the best $\lambda$:

Remove[no, ne, ne2, vo, ve, ve2, θ, λ];

no[λ_] := Sqrt[(2.7359 + 0.01878/((λ*10^-3)^2 - 0.01822) - 0.01354 (λ*10^-3)^2)];

ne[λ_] := Sqrt[(2.3753 + 0.01224/((λ*10^-3)^2 - 0.01667) - 0.01516 (λ*10^-3)^2)];

ne2[θ_, λ_] := Sqrt[ 1/((Cos[θ])^2/(no[λ])^2 + (Sin[θ])^2/(ne[λ])^2)];  

θ = 0.5022905464984275;

vo[λ_] = 1/(no[λ] - λ D[no[λ], λ]);

ve[λ_] = 1/(ne[λ] - λ D[ne[λ], λ]);

ve2[θ_, λ_] = 1/(ne2[θ, λ] - λ D[ne2[θ, λ], λ]);

FindRoot[2/ve2[θ, λ/2] == 1/vo[λ] + 1/ve2[θ, λ], {λ, 100, 2000}]

With the above codes, I can obtain the results of 1514.73.

$\endgroup$

closed as off-topic by m_goldberg, LCarvalho, LLlAMnYP, Bob Hanlon, rcollyer Nov 7 '17 at 16:28

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." – m_goldberg, LCarvalho, LLlAMnYP, Bob Hanlon, rcollyer
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ This Plot3D[Norm[ne2[λ/2, θ]/(λ/2) - (no[λ]/λ + ne2[λ, θ]/λ)] + Norm[2/ve2[λ/2, θ] - (1/vo[λ] + 1/ve2[λ, θ])], {λ,1000,2000}, {θ,0.1,1}, PlotRange->{0,4}, PlotPoints->100, ViewPoint->Front, ImageSize->19*72] might give a little appreciation why it is having so much difficulty finding the root you desire if you click your mouse inside the finished plot and then VERY gently drag up until you are looking straight across the xy plane. To better see some of those fuzzy vertical planes would require bumping the PlotPoints option even higher and making the plot even slower to render. $\endgroup$ – Bill Oct 28 '17 at 18:33
  • $\begingroup$ Many thanks to Bill. Your comments are helpful to me. I find there was a mistake in my previous codes and I have solved this problem. $\endgroup$ – user14634 Oct 31 '17 at 15:56
1
$\begingroup$

This is not an answer, but a comment that uses a plot to make its point.

Consider the plots

Plot3D[{ne2[λ/2, θ]/(λ/2), no[λ]/λ + ne2[λ, θ]/λ}, {λ, 1000, 2000}, {θ, .1, 1}]

plot1

Plot3D[{2/ve2[λ/2, θ], 1/vo[λ] + 1/ve2[λ, θ]}, {λ, 1000, 2000}, {θ, .1, 1}]

plot2

The surfaces represented by the rhs and lhs of your 1st equation don't intersect in the region of interest. The surfaces represented by the rhs and lhs of your 2nd equation intersect in many closely spaced but separate curves. Does this not give you some idea of why FindRoot has difficulty with your system of equations?

$\endgroup$
  • $\begingroup$ Many thanks to m_goldberg. Your figures and comments are helpful to me. I find there was a mistake in my previous codes and I have solved this problem. $\endgroup$ – user14634 Oct 31 '17 at 15:58
  • $\begingroup$ I made a wrong definition for ne2[[Theta]_, [Lambda]_] and ve2[[Lambda]_, [Theta]_], after correct this, these two equations can be solved. $\endgroup$ – user14634 Oct 31 '17 at 16:01
1
$\begingroup$

I made wrong definitions for ne2 and ve2 in the previous version. After correct this, the problem was solved as follow.

Remove[no, ne, ne2, vo, ve, ve2, \[Theta], \[Lambda]];
no[\[Lambda]_] := \[Sqrt](2.7359 +  0.01878/((\[Lambda]*10^-3)^2 - 0.01822) -  0.01354 (\[Lambda]*10^-3)^2);
ne[\[Lambda]_] := \[Sqrt](2.3753 + 0.01224/((\[Lambda]*10^-3)^2 - 0.01667) -      0.01516 (\[Lambda]*10^-3)^2);
ne2[\[Theta]_, \[Lambda]_] := Sqrt[  1/((Cos[\[Theta]])^2/(no[\[Lambda]])^2 + (Sin[\[Theta]])^2/(ne[\[Lambda]])^2)];
vo[\[Lambda]_] = 1/(  no[\[Lambda]] - \[Lambda] D[no[\[Lambda]], \[Lambda]]);
ve[\[Lambda]_] = 1/(  ne[\[Lambda]] - \[Lambda] D[ne[\[Lambda]], \[Lambda]]);
ve2[\[Theta]_, \[Lambda]_] = 1/(  ne2[\[Lambda], \[Theta]] - \[Lambda] D[ne2[\[Lambda], \[Theta]], \[Lambda]]);


Plot3D[{ne2[\[Theta], \[Lambda]/2]/(\[Lambda]/2), no[\[Lambda]]/\[Lambda] + ne2[\[Theta], \[Lambda]]/\[Lambda]}, {\[Lambda], 1510, 1520}, {\[Theta], .4, .6}]

Plot3D[{2/ve2[\[Theta], \[Lambda]/2],   1/vo[\[Lambda]] + 1/ve2[\[Theta], \[Lambda]]}, {\[Lambda], 1510,  1520}, {\[Theta], .4, .6}]

FindRoot[{ne2[\[Theta], \[Lambda]/2]/(\[Lambda]/2) ==  no[\[Lambda]]/\[Lambda] + ne2[\[Theta], \[Lambda]]/\[Lambda], 2/ve2[\[Theta], \[Lambda]/2] ==   1/vo[\[Lambda]] + 1/ve2[\[Theta], \[Lambda]]}, {{\[Lambda], 1514, 1000, 2000}, {\[Theta], 0.5, 0.1, 1}}]

The results are

enter image description here

Finally, many thanks to Bill and m_goldberg. Your comments inspired me to find the solution to the error.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.