MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: want real solutions instead of complex ones

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66521] Re: want real solutions instead of complex ones
  • From: bghiggins at ucdavis.edu
  • Date: Wed, 17 May 2006 03:31:11 -0400 (EDT)
  • References: <e4biic$175$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Nabeel,
Let the solutions be stored in the variable sol. Then use a DeleteCases
to eliminate the complex roots using the following code:


DeleteCases[sol, {Rule[x,Complex[_,_]],Rule[y,Complex[_,_]]},8]


{{x->-2.33,y->5.4377},{x->-1.41347,y->2.03811},{x->-0.261794,y->2.31834},
{x->-0.275848,y->1.93711},{ x->2.21859,y->0.938096},
{ x->2.03382,y->0.9278},{x->1.96041,y->1.08106},
{x->-0.675933,y->.405236},{x->1.51819,y->2.29567},
{x->0.635828,y->0.598477},{x->0.27623,y->0.513478}}

Hope this helps,
Cheers,

Brian


Nabeel Butt wrote:
> Dear All,
>           I solve a system of 10 equations and get real solution along with
> complex ones.Is there a way such that I get only real solutions satisfying
> given constraints using NSolve.
>
>    Find attached the file.
>
>        regards,
>
>         Nabeel Butt
>
> (************** Content-type: application/mathematica **************
>                      CreatedBy='Mathematica 5.2'
>
>                     Mathematica-Compatible Notebook
>
> This notebook can be used with any Mathematica-compatible
> application, such as Mathematica, MathReader or Publicon. The data
> for the notebook starts with the line containing stars above.
>
> To get the notebook into a Mathematica-compatible application, do
> one of the following:
>
> * Save the data starting with the line of stars above into a file
>   with a name ending in .nb, then open the file inside the
>   application;
>
> * Copy the data starting with the line of stars above to the
>   clipboard, then use the Paste menu command inside the application.
>
> Data for notebooks contains only printable 7-bit ASCII and can be
> sent directly in email or through ftp in text mode.  Newlines can be
> CR, LF or CRLF (Unix, Macintosh or MS-DOS style).
>
> NOTE: If you modify the data for this notebook not in a Mathematica-
> compatible application, you must delete the line below containing
> the word CacheID, otherwise Mathematica-compatible applications may
> try to use invalid cache data.
>
> For more information on notebooks and Mathematica-compatible
> applications, contact Wolfram Research:
>   web: http://www.wolfram.com
>   email: info at wolfram.com
>   phone: +1-217-398-0700 (U.S.)
>
> Notebook reader applications are available free of charge from
> Wolfram Research.
> *******************************************************************)
>
> (*CacheID: 232*)
>
>
> (*NotebookFileLineBreakTest
> NotebookFileLineBreakTest*)
> (*NotebookOptionsPosition[     10126,        222]*)
> (*NotebookOutlinePosition[     10768,        244]*)
> (*  CellTagsIndexPosition[     10724,        240]*)
> (*WindowFrame->Normal*)
>
>
>
> Notebook[{
>
> Cell[CellGroupData[{
> Cell[BoxData[{
>     \(Clear[x, y, a, b, c, d, e, f, g, h]\), "\[IndentingNewLine]",
>     \(\(f[x_, y_] :=
>         100*\((y - x^2)\)^2 + \((1 - x)\)^2;\)\), "\[IndentingNewLine]",
>     \(\(f1[x_, y_]\  = \
>         D[100*\((y - x^2)\)^2 + \((1 - x)\)^2,
>           x];\)\), "\[IndentingNewLine]",
>     \(\(f2[x_, y_]\  =
>         D[100*\((y - x^2)\)^2 + \((1 - x)\)^2,
>           y];\)\), "\[IndentingNewLine]",
>     \(\(a\  = \ f1[1.5, 1.5];\)\), "\[IndentingNewLine]",
>     \(\(b\  = \ f2[1.5, 1.5];\)\), "\[IndentingNewLine]",
>     \(\(p[x_, y_] =
>         1\/\(1 - y\) + 1\/\(x + 2  y - 4\) +
>           1\/\(4  y - x - 1\);\)\), "\[IndentingNewLine]",
>     \(\(p1[x_, y_]\  = \
>         D[1\/\(1 - y\) + 1\/\(x + 2  y - 4\) + 1\/\(4  y - x - 1\),
>           x];\)\), "\[IndentingNewLine]",
>     \(\(p2[x_, y_]\  = \
>         D[1\/\(1 - y\) + 1\/\(x + 2  y - 4\) + 1\/\(4  y - x - 1\),
>           y];\)\), "\[IndentingNewLine]",
>     \(\(c\  = \ p1[1.5, 1.5];\)\), "\[IndentingNewLine]",
>     \(\(d\  = \ p2[1.5, 1.5];\)\), "\[IndentingNewLine]",
>     \(\(e\  = \ {{a, b}} . {{c}, {d}};\)\), "\[IndentingNewLine]",
>     \(\(f\  = \ {{c, d}} . {{c}, {d}};\)\), "\[IndentingNewLine]",
>     \(r\  = \ \(-\({{a, b}} . {{c}, {d}}\/{{c,
>                   d}} . {{c}, {d}}\)\)\), "\[IndentingNewLine]",
>     \(\(\(h[x_, y_] :=
>         100*\((y - x^2)\)^2 + \((1 - x)\)^2 +
>           32.8184*\((1\/\(1 - y\) + 1\/\(x + 2  y - 4\) +
>                 1\/\(4  y - x - 1\))\);\)\(\[IndentingNewLine]\)
>     \)\), "\[IndentingNewLine]",
>     \(\(\(h1[x_, y_] =
>       D[100*\((y - x^2)\)^2 + \((1 - x)\)^2 +
>           32.8184*\((1\/\(1 - y\) + 1\/\(x + 2  y - 4\) +
>                 1\/\(4  y - x - 1\))\), x]\)\(\[IndentingNewLine]\)
>     \)\), "\[IndentingNewLine]",
>     \(h2[x_, y_] =
>       D[100*\((y - x^2)\)^2 + \((1 - x)\)^2 +
>           32.8184*\((1\/\(1 - y\) + 1\/\(x + 2  y - 4\) +
>                 1\/\(4  y - x - 1\))\),
>         y]\[IndentingNewLine]\), "\[IndentingNewLine]",
>     \(NSolve[\(-2\)\ \((1 - x)\) - 400\ x\ \((\(-x^2\) + y)\) +
>             32.8184*\((\(-\(1\/\((\(-4\) + x + 2\ y)\)^2\)\) +
>                   1\/\((\(-1\) - x + 4\ y)\)^2)\)\  \[Equal] \ 0 &&
>         200\ \((\(-\((x)\)^2\) + y)\) +
>             32.8184*\ \((1\/\((1 - y)\)^2 - 2\/\((\(-4\) + x + 2\ y)\)^2 -
>                   4\/\((\(-1\) - x + 4\ y)\)^2)\)\  \[Equal] \ 0, {x,
>         y}]\)}], "Input"],
>
> Cell[BoxData[
>     \({{32.8184040680618`}}\)], "Output"],
>
> Cell[BoxData[
>     \(\(-2\)\ \((1 - x)\) - 400\ x\ \((\(-x\^2\) + y)\) +
>       32.8184`\ \((\(-\(1\/\((\(-4\) + x + 2\ y)\)\^2\)\) +
>             1\/\((\(-1\) - x + 4\ y)\)\^2)\)\)], "Output"],
>
> Cell[BoxData[
>     \(200\ \((\(-x\^2\) + y)\) +
>       32.8184`\ \((1\/\((1 - y)\)\^2 - 2\/\((\(-4\) + x + 2\ y)\)\^2 -
>             4\/\((\(-1\) - x + 4\ y)\)\^2)\)\)], "Output"],
>
> Cell[BoxData[
>     \({x \[Rule] 2.2185900920287023`,
>       y \[Rule] 0.938095512431111`}\)], "Output"],
>
> Cell[BoxData[
>     \({{x \[Rule] \(-2.3300039158474948`\),
>         y \[Rule]
>           5.437702408009029`}, {x \[Rule] \(-1.3080121812787795`\) +
>             1.3189274376479279`\ \[ImaginaryI],
>         y \[Rule] \(-0.021135501562510876`\) -
>             3.448843945185865`\ \[ImaginaryI]}, {x \[Rule] \
> \(-1.3080121812787795`\) - 1.3189274376479279`\ \[ImaginaryI],
>         y \[Rule] \(-0.021135501562510876`\) +
>             3.448843945185865`\ \[ImaginaryI]}, {x \[Rule] \
> \(-1.413473641581122`\),
>         y \[Rule]
>           2.038113944541813`}, {x \[Rule] \(\(3.016610621026707`\)\(\
> \[InvisibleSpace]\)\) + 0.17529083922050717`\ \[ImaginaryI],
>         y \[Rule] \(\(1.0028055240560971`\)\(\[InvisibleSpace]\)\) +
>             0.02942470020512421`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(3.016610621026707`\)\(\[InvisibleSpace]\)\) -
>             0.17529083922050717`\ \[ImaginaryI],
>         y \[Rule] \(\(1.0028055240560971`\)\(\[InvisibleSpace]\)\) -
>             0.02942470020512421`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(3.002021155610634`\)\(\[InvisibleSpace]\)\) +
>             0.061056545573892125`\ \[ImaginaryI],
>         y \[Rule] \(\(1.0009681663732772`\)\(\[InvisibleSpace]\)\) +
>             0.029874542082381144`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(3.002021155610634`\)\(\[InvisibleSpace]\)\) -
>             0.061056545573892125`\ \[ImaginaryI],
>         y \[Rule] \(\(1.0009681663732772`\)\(\[InvisibleSpace]\)\) -
>             0.029874542082381144`\ \[ImaginaryI]}, {x \[Rule] \
> \(-0.26179372754660113`\),
>         y \[Rule]
>           2.3183385204212894`}, {x \[Rule] \(\(1.7426724070056736`\)\(\
> \[InvisibleSpace]\)\) - 1.1311994090477295`\ \[ImaginaryI],
>         y \[Rule] \(\(1.7605621392036186`\)\(\[InvisibleSpace]\)\) -
>             3.9437915975175697`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(1.7426724070056736`\)\(\[InvisibleSpace]\)\) +
>             1.1311994090477295`\ \[ImaginaryI],
>         y \[Rule] \(\(1.7605621392036186`\)\(\[InvisibleSpace]\)\) +
>             3.9437915975175697`\ \[ImaginaryI]}, {x \[Rule] \
> \(-0.27584848595520134`\),
>         y \[Rule]
>           1.9371110378007257`}, {x \[Rule] \(\(2.4037452326588`\)\(\
> \[InvisibleSpace]\)\) + 0.04717248607553815`\ \[ImaginaryI],
>         y \[Rule] \(\(0.8486220559527325`\)\(\[InvisibleSpace]\)\) -
>             0.024693334971704436`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(2.4037452326588`\)\(\[InvisibleSpace]\)\) -
>             0.04717248607553815`\ \[ImaginaryI],
>         y \[Rule] \(\(0.8486220559527325`\)\(\[InvisibleSpace]\)\) +
>             0.024693334971704436`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(2.2618824064519516`\)\(\[InvisibleSpace]\)\) +
>             0.05540192878333497`\ \[ImaginaryI],
>         y \[Rule] \(\(0.8129374326537959`\)\(\[InvisibleSpace]\)\) -
>             0.025761333389901043`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(2.2618824064519516`\)\(\[InvisibleSpace]\)\) -
>             0.05540192878333497`\ \[ImaginaryI],
>         y \[Rule] \(\(0.8129374326537959`\)\(\[InvisibleSpace]\)\) +
>             0.025761333389901043`\ \[ImaginaryI]}, {x \[Rule]
>           2.218590092050343`,
>         y \[Rule] 0.938095512444044`}, {x \[Rule] 2.0338209633766913`,
>         y \[Rule] 0.9277996749908699`}, {x \[Rule] 1.9604113947666808`,
>         y \[Rule] 1.0810644610825255`}, {x \[Rule] \(-0.6759326096756758`\),
>         y \[Rule]
>           0.4052355182131105`}, {x \[Rule] \(-0.018384587735958014`\) +
>             0.010882497228183506`\ \[ImaginaryI],
>         y \[Rule] \(\(1.0709002353096357`\)\(\[InvisibleSpace]\)\) -
>             0.38887940149741124`\ \[ImaginaryI]}, {x \[Rule] \
> \(-0.018384587735958014`\) - 0.010882497228183506`\ \[ImaginaryI],
>         y \[Rule] \(\(1.0709002353096357`\)\(\[InvisibleSpace]\)\) +
>             0.38887940149741124`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(0.23155647108023092`\)\(\[InvisibleSpace]\)\) +
>             0.7301095692582488`\ \[ImaginaryI],
>         y \[Rule] \(-0.4730247966511824`\) +
>             0.33908560422426737`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(0.23155647108023092`\)\(\[InvisibleSpace]\)\) -
>             0.7301095692582488`\ \[ImaginaryI],
>         y \[Rule] \(-0.4730247966511824`\) -
>             0.33908560422426737`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(1.468860686921461`\)\(\[InvisibleSpace]\)\) +
>             0.052407446381800143`\ \[ImaginaryI],
>         y \[Rule] \(\(1.14990789586539`\)\(\[InvisibleSpace]\)\) -
>             0.014568422203746424`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(1.468860686921461`\)\(\[InvisibleSpace]\)\) -
>             0.052407446381800143`\ \[ImaginaryI],
>         y \[Rule] \(\(1.14990789586539`\)\(\[InvisibleSpace]\)\) +
>             0.014568422203746424`\ \[ImaginaryI]}, {x \[Rule]
>           1.5181877213040338`,
>         y \[Rule]
>           2.2956733779000835`}, {x \[Rule] \(\(0.1477065626038482`\)\(\
> \[InvisibleSpace]\)\) + 0.02702054414757287`\ \[ImaginaryI],
>         y \[Rule] \(-0.012671023162213337`\) -
>             0.21593683662093668`\ \[ImaginaryI]}, {x \[Rule] \
> \(\(0.1477065626038482`\)\(\[InvisibleSpace]\)\) -
>             0.02702054414757287`\ \[ImaginaryI],
>         y \[Rule] \(-0.012671023162213337`\) +
>             0.21593683662093668`\ \[ImaginaryI]}, {x \[Rule]
>           0.6358277338359912`,
>         y \[Rule] 0.5984768668419583`}, {x \[Rule] 0.2762302599150268`,
>         y \[Rule] 0.5134777549844451`}}\)], "Output"]
> }, Open  ]],
>
> Cell[BoxData[
>     \(\[AliasDelimiter]\)], "Input"]
> },
> FrontEndVersion->"5.2 for Microsoft Windows",
> ScreenRectangle->{{0, 800}, {0, 517}},
> WindowSize->{495, 487},
> WindowMargins->{{3, Automatic}, {Automatic, 0}}
> ]
>
> (*******************************************************************
> Cached data follows.  If you edit this Notebook file directly, not
> using Mathematica, you must remove the line containing CacheID at
> the top of  the file.  The cache data will then be recreated when
> you save this file from within Mathematica.
> *******************************************************************)
>
> (*CellTagsOutline
> CellTagsIndex->{}
> *)
>
> (*CellTagsIndex
> CellTagsIndex->{}
> *)
>
> (*NotebookFileOutline
> Notebook[{
>
> Cell[CellGroupData[{
> Cell[1776, 53, 2397, 48, 798, "Input"],
> Cell[4176, 103, 55, 1, 29, "Output"],
> Cell[4234, 106, 192, 3, 64, "Output"],
> Cell[4429, 111, 178, 3, 64, "Output"],
> Cell[4610, 116, 102, 2, 29, "Output"],
> Cell[4715, 120, 5342, 96, 580, "Output"]
> }, Open  ]],
> Cell[10072, 219, 50, 1, 30, "Input"]
> }
> ]
> *)
>
>
>
> (*******************************************************************
> End of Mathematica Notebook file.
> *******************************************************************)


  • Prev by Date: Re: compound symmetrical primes
  • Next by Date: Re: Lists and rules
  • Previous by thread: Re: want real solutions instead of complex ones
  • Next by thread: Re: want real solutions instead of complex ones