From: Pratip Chakraborty on 30 May 2010 06:47 Dear Dave, here goes my solution. func[c_?NumericQ,m_?NumericQ,n_?NumericQ]:=FindRoot[{a-b==2*Pi*(m-n)+ArcTan[(a-b)/c],a+b==2*Pi*(m+n)},{{a,2 I+1},{b,-2 I+1}}] Needs["PlotLegends`"]; Clear[m,n]; Error={a-b==2*Pi*(m-n)+ArcTan[(a-b)/c],a+b==2*Pi*(m+n)}/.a_==b_-> a-b; (* Lets vary the c from 5 to 100 with a distance between points being .1 *) cval=Cases[Range[5,100,.1],Except[0]]; m=3;n=5; {Error1,Error2}=Map[(Error/.c-> #/.func[#,m,n])&,cval]//Transpose; {AIm,BIm}=Map[({Im[a],Im[b]}/.func[#,m,n])&,cval]//Transpose; (* Lets plot the imaginary parts *) ListLinePlot[{Transpose[{cval,AIm}],Transpose[{cval,BIm}]},Frame-> True,Axes-> None,PlotRange-> All,PlotLegend->{"Im(a)", "Im(b)"},LegendPosition->{1.1,-0.4}] If you want the real part also {ARe,BRe}=Map[({Re[a],Re[b]}/.func[#,m,n])&,cval]//Transpose; (* Lets plot the real parts *) ListLinePlot[{Transpose[{cval,ARe}],Transpose[{cval,BRe}]},Frame-> True,Axes-> None,PlotRange-> All,PlotLegend->{"Re(a)", "Re(b)"},LegendPosition->{1.1,-0.4}] Regards, Pratip On Sat, May 29, 2010 at 10:43 AM, JustanotherDave <david.holdaway(a)gmail.com>wrote: > I'm having trouble getting Mathematica to plot what I would like from > a system of equations. I have the function > > f[c_?NumericQ, m_?NumericQ, n_?NumericQ] := > FindRoot[{a - b == 2*Pi*(m - n) + ArcTan[(a - b)/c], > a + b == 2*Pi*(m + n)}, {{a, 2 I + 1}, {b, -2 I + 1}}] > > Which evaluates to something like {a -> 13.333 + 2.99972*10^-20 I, b - > > -13.333 - 2.99972*10^-20 I} > What I would like is to be able to plot the imaginary values of a and > b on the same graph (varying the parameter c, keeping m and n > constant) but I'm not sure how to convert the FindRoot output to > plotable values > >
|
Pages: 1 Prev: Connecting to a remote MySQL database via SSL Next: loop for with plot |