Message Boards Message Boards

0
|
4481 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Problems in getting Real number solutions in NSolve

Posted 10 years ago

Hello, Wolfram,

Simply speaking, the purpose of this small programming is to get the Real values of An and Ak. I think that this is a very simple equation to solve, but I have no idea why NSolve does not give any Real solution (even Imaginary solution). Could you help me ? I pasted the context of the programming below.

Thank you in advance,

n = 2.48; k = 4.38; (* dn/d\[Eta], dk/d\[Eta] *) \[Epsilon] = (n + 
   I k)^2; \[Eta] = -5 10^-3; 
d\[Epsilon][An_, Ak_] := 2 (n + I k) (An + I Ak) \[Eta];
rp[\[Theta]_] := (\[Epsilon] Cos[\[Theta]] - (\[Epsilon] - 
       Sin[\[Theta]]^2)^0.5)/(\[Epsilon] Cos[\[Theta]] + (\[Epsilon] -
        Sin[\[Theta]]^2)^0.5);
drp[\[Theta]_, An_, 
   Ak_] := ((d\[Epsilon][An, Ak] Cos[\[Theta]] - 
        d\[Epsilon][An, 
          Ak]/(2 (\[Epsilon] - 
             Sin[\[Theta]]^2)^0.5)) (\[Epsilon] Cos[\[Theta]] + (\
\[Epsilon] - 
          Sin[\[Theta]]^2)^0.5) - (\[Epsilon] Cos[\[Theta]] - (\
\[Epsilon] - Sin[\[Theta]]^2)^0.5) (d\[Epsilon][An, 
          Ak] Cos[\[Theta]] + 
        d\[Epsilon][An, 
          Ak]/(2 (\[Epsilon] - 
             Sin[\[Theta]]^2)^0.5)))/(\[Epsilon] Cos[\[Theta]] + (\
\[Epsilon] - Sin[\[Theta]]^2)^0.5)^2;
NSolve[{2 Re[drp[10.0 \[Pi]/180, An, Ak]/rp[10.0 \[Pi]/180]] == 
   0.001509, 
  2 Re[drp[60.0 \[Pi]/180, An, Ak]/rp[60.0 \[Pi]/180]] == 
   0.00287}, {An, Ak}]
Attachments:
POSTED BY: hwoarang Polar
4 Replies
Posted 10 years ago

Thank you soooo much. It really works.

POSTED BY: hwoarang Polar

NSolve does not know that your variables are real and cannot figure out what are the real vs imaginary parts of the equations. The variant below will do what you have in mind.

NSolve[{2 ComplexExpand[ 
     Re[drp[10.0 \[Pi]/180, An, Ak]/rp[10.0 \[Pi]/180]]] == 0.001509, 
  2 ComplexExpand[
     Re[drp[60.0 \[Pi]/180, An, Ak]/rp[60.0 \[Pi]/180]]] == 
   0.00287}, {An, Ak}]

(* {{An -> 1.24022687578, Ak -> -1.48615978481}} *)
POSTED BY: Daniel Lichtblau
Posted 10 years ago

But, this does not work in my system (ver 7.0). This does not make any difference. And if I want to get the Real numbers solutions(not Imaginary numbers) of An and Ak, do I need to define An, Ak as Real numbers somewhere ? Actually, solutions of An and Ak should be real numbers because I used An and Ak, which are given from literatures, 2 Re[drp[10.0 [Pi]/180, An, Ak]/rp[10.0 [Pi]/180] gives 0.00144 (quite similar value used in my program).

Thank you for the help.

POSTED BY: hwoarang Polar
Posted 10 years ago

A number of small, but significant changes

In[1]:= n = 2.48; k = 4.38;(*dn/d[Eta],dk/d[Eta]*)
\[Epsilon] = (n + I k)^2; \[Eta] = -5 10^-3;
d\[Epsilon][An_, Ak_] := 2 (n + I k) (An + I Ak) \[Eta]; 
rp[\[Theta]_] := (\[Epsilon] Cos[\[Theta]] - Sqrt[\[Epsilon] - Sin[\[Theta]]^2])/(\[Epsilon] Cos[\[Theta]] +
Sqrt[\[Epsilon] - Sin[\[Theta]]^2]); 
drp[\[Theta]_, An_, Ak_] := ((d\[Epsilon][An, Ak] Cos[\[Theta]] - d\[Epsilon][An, Ak]/(2 Sqrt[\[Epsilon] -
Sin[\[Theta]]^2])) (\[Epsilon] Cos[\[Theta]] + Sqrt[\[Epsilon] - Sin[\[Theta]]^2]) - (\[Epsilon] Cos[\[Theta]] -
Sqrt[\[Epsilon] - Sin[\[Theta]]^2]) (d\[Epsilon][An, Ak] Cos[\[Theta]] + d\[Epsilon][An, Ak]/(2 Sqrt[\[Epsilon] -
Sin[\[Theta]]^2])))/(\[Epsilon] Cos[\[Theta]] + Sqrt[\[Epsilon] - Sin[\[Theta]]^2])^2;
sol = Simplify[NSolve[{
    2 Re[drp[10.0 \[Pi]/180, An, Ak]/rp[10.0 \[Pi]/180]] == 0.001509, 
    2 Re[drp[60.0 \[Pi]/180, An, Ak]/rp[60.0 \[Pi]/180]] == 0.00287}, {An, Ak}]]

During evaluation of In[1]:= NSolve::svars: Equations may not give solutions for all "solve" variables. >>

During evaluation of In[1]:= NSolve::ratnz: NSolve was unable to solve the system with inexact coefficients. The answer was
obtained by solving a corresponding exact system and numericizing the result. >>

Out[3]= {{Ak -> (-1.48616 - 1.24023 I) - (1. - 1.96183*10^-16 I) Im[An] + (0. + 1. I) Re[An]}}

(*thus it appears*)
Ak == -1.48616 - 1.24023 I + I An
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract