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


Groups > comp.soft-sys.math.mathematica > #10879

Re: Separating square roots

From Peter Pein <petsie@dordos.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Separating square roots
Date 2012-07-11 06:23 +0000
Message-ID <jtj656$5or$1@smc.vnet.net> (permalink)
References <jtgbrm$49j$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Am 10.07.2012 06:42, schrieb rhartley.anu@gmail.com:
> I have an expression which is a sum of terms, some monomials
> and others involving square roots, such as
> A = 3  + 5 x^2 + 7 x + Sqrt[5+x] + 7 x Sqrt[5+x] (but much more complicated).
> I want to solve this, which involves separating terms with the square root
> from those that do not have a square root, then squaring each.
>
> I can not work out how to separate out those terms that have the square
> root.  I do not want to hard code, such as nosqrt = A[[1]] + A[[2]] , etc.
> Can anyone help?
>
> r
>
>

This will work if all square roots are of the form Sqrt[a +/- b] (I 
think). And you'll get additional solutions which do not solve A==0.

Try:

A = 3 + 5*x^2 + 7*x + Sqrt[5 + x] + 7*x*Sqrt[5 + x];
sep = Apply[Plus,
   With[{sel = FreeQ[#1, _^(1/2)] & },
     Split[SortBy[List @@ #1, sel], sel[#1] == sel[#2] & ]
   ],
{1}] & ;
tmp = Function[x, Evaluate[Expand[Subtract @@ (sep[A]^2)]]]
soln = Select[
   ({x -> #1} & ) /@ Table[Root[tmp, k], {k, Exponent[tmp[x], x]}],
   10^(-8) > Abs[N[A /. #1]] &
]
soln === Solve[A == 0, x, Quartics -> False]
nx0 = Chop[N[x /. soln]]

==>
Function[x,-4+29 x+180 x^2-21 x^3-25 x^4]
{{x->Root[4-29 #1-180 #1^2+21 #1^3+25 #1^4&,1]},
  {x->Root[4-29 #1-180 #1^2+21 #1^3+25 #1^4&,2]}}
True
{-3.06206,-0.246324}

Peter

P.S.: to visualize additional roots, enter with the results from above:

Plot[Evaluate[(Sign[#1]*Log[1 + Abs[#1]] & )[{A, tmp[x]}]], 
Evaluate[Prepend[(x /. NSolve[tmp[x] == 0, x, Reals])[[{1, -1}]] + 
{-0.1, 0.1},
     x]], Frame -> True, Axes -> {True, False}, AxesStyle -> Lighter[Gray],
   Epilog -> {Red, PointSize[1/100], Point[Thread[{Cases[nx0, _Real], 
0}]]}, PlotRange -> All]

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Separating square roots rhartley.anu@gmail.com - 2012-07-10 04:42 +0000
  Re: Separating square roots Peter Pein <petsie@dordos.net> - 2012-07-11 06:23 +0000

csiph-web