Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8697 > unrolled thread

Re: Complex and Solve

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-02-22 10:32 +0000
Last post2012-02-23 10:46 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Complex and Solve Bob Hanlon <hanlonr357@gmail.com> - 2012-02-22 10:32 +0000
    Re: Complex and Solve howard.lovatt@gmail.com - 2012-02-23 10:46 +0000

#8697 — Re: Complex and Solve

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-02-22 10:32 +0000
SubjectRe: Complex and Solve
Message-ID<ji2g7c$k9m$1@smc.vnet.net>
Use Reduce rather than Solve

$Assumptions = rfe > 0 && l > 0;

r = 1;
\[Omega] = 300;
vrms = 2;
irms = 1/2;
\[Phi] = 30 Degree;

impedance = r + 1/(1/rfe + 1/(I \[Omega] l)) // FullSimplify;

voltage = vrms (Cos[\[Phi]] + I Sin[\[Phi]]) // Simplify;

Reduce[
  {irms == voltage/impedance, $Assumptions},
  {rfe, l}, Backsubstitution -> True] // ToRules

{rfe -> (17 - 4*Sqrt[3])/(-1 + 2*Sqrt[3]), l -> (1/600)*(17 - 4*Sqrt[3])}

% // N

{rfe -> 4.08741, l -> 0.0167863}


Bob Hanlon

On Tue, Feb 21, 2012 at 6:15 AM,  <howard.lovatt@gmail.com> wrote:
> Hi,
>
> I am seeing something strange when trying to use Solve to find the solution to an equation involving complex numbers. If I enter the complex numbers in the usual Cartesian form then Solve nor NSolve work. If I use the matrix form for complex numbers then Solve works. The matrix form is long winded and not obvious, so I was wondering if there was a better way - see example below particularly outputs 9 and 10?
>
> The problem seems to be that Mathematica can't manipulate the real and imaginary parts separately and the reason that the matrix form works is that it forces separate manipulation of the parts.
>
> Thanks in advance for any advice,
>
>  -- Howard.
>
> =========================
> Fit to inductor model (series r parallel rfe l)
> In[1]:= $Assumptions=rfe>0&&l>0;
> In[2]:= r=1;
> In[3]:= \[Omega]=300;
> In[4]:= vrms=2;
> In[5]:= irms=1/2;
> In[6]:= \[Phi]=30 Degree;
> Conventional Mathematica - Doesn' t work!!!! - See Matrix Form below
> In[7]:= impeadance=r+1/(1/rfe+1/(I \[Omega] l))//FullSimplify//Comple=
xExpand
> Out[7]= 1+(90000 l^2 rfe)/(90000 l^2+rfe^2)+(300 I l rfe^2)/(90000 l^2+rfe^2)
> In[8]:= voltage=vrms(Cos[\[Phi]]+I Sin[\[Phi]])//Simplify//ComplexExpand
> Out[8]= I+Sqrt[3]
>
> In[9]:= solution=Solve[irms==voltage/impeadance,{rfe,l}][[1]]//FullSimplify
> During evaluation of In[9]:= Solve::svars: Equations may not give solutions for all "solve" variables. >>
> Out[9]= {l->-(I/(300 (1/((-1+2 I)+2 Sqrt[3])-1/rfe)))}
>
> In[10]:= nsolution=NSolve[irms==voltage/impeadance,{rfe,l}]
> During evaluation of In[10]:= NSolve::infsolns: Infinite solution set has dimension at least 1. Returning intersection of solutions with (151145 l/110742-(17791 rfe)/18457 == 1. >>
> Out[10]= {{rfe->-1.0368-0.0037973 I,l->0.000448264 -0.00268184 I},{rfe->2.47291 +1.99217 I,l->2.47917 +1.40697 I}}
>
> Matrix Form
> http : // en.wikipedia.org/wiki/Complex_number # Matrix_representation _of _complex _numbers
> In[11]:= mr={{r,0},{0,r}}
> Out[11]= {{1,0},{0,1}}
> In[12]:= mrfe={{rfe,0},{0,rfe}}
> Out[12]= {{rfe,0},{0,rfe}}
> In[13]:= ml={{0,-\[Omega] l},{\[Omega] l,0}}
> Out[13]= {{0,-300 l},{300 l,0}}
> In[14]:= mimpeadance=mr+Inverse[Inverse[mrfe]+Inverse[ml]]//FullSimplify
> Out[14]= {{1+1/(1/rfe+rfe/(90000 l^2)),-((300 l rfe^2)/(90000 l^2+rfe^2)},{(300 l rfe^2)/(90000 l^2+rfe^2),1+1/(1/rfe+rfe/(90000 l^2))}}
> In[15]:= mvoltage=vrms{{Cos[\[Phi]],-Sin[\[Phi]]},{Sin[\[Phi]],Cos[\[Phi]]}}//Simplify
> Out[15]= {{Sqrt[3],-1},{1,Sqrt[3]}}
> In[16]:= mcurrent=mvoltage.Inverse[mimpeadance]//FullSimplify
> Out[16]= {{(Sqrt[3] rfe^2+300 l rfe^2+90000 Sqrt[3] l^2 (1+rfe))/(rfe^2+90000 l^2 (1+rfe)^2),-((rfe^2-300 Sqrt[3] l rfe^2+90000 l^2 (1+rfe))/(rfe^2+90000 l^2 (1+rfe)^2))},{(rfe^2-300 Sqrt[3] l rfe^2+90000 l^2 (1+rfe))/(rfe^2+90000 l^2 (1+rfe)^2),(Sqrt[3] rfe^2+300 l rfe^2+90000 Sqrt[3] l^2 (1+rfe))/(rfe^2+90000 l^2 (1+rfe)^2)}}
> In[17]:= mirms={{irms,0},{0,irms}}
> Out[17]= {{1/2,0},{0,1/2}}
> In[18]:= msolution=Solve[mirms==mcurrent,{rfe,l}][[1]]
> Out[18]= {rfe->(24709-15142 Sqrt[3])/(-4937+2636 Sqrt[3]),l->(-45426+24709 Sqrt[3])/(-1184400+593400 Sqrt[3])}
> In[19]:= msolution//N
> Out[19]= {rfe->4.08741,l->0.0167863}
>

[toc] | [next] | [standalone]


#8700

Fromhoward.lovatt@gmail.com
Date2012-02-23 10:46 +0000
Message-ID<ji55ek$76i$1@smc.vnet.net>
In reply to#8697
Thanks Bob,

Your solution is much better than mine. I had no idea that Reduce could be used like you showed.

Bizarre that Solve and Reduce behave so differently!

Thanks again,

 -- Howard.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web