8
$\begingroup$

I have a messy expression of variables that I would like to simplify under the assumption that certain ratios of the variables are small. For example, consider $\sqrt{x+y}\;$ expanded for small $\frac{y}{x}$. That is, $x >> y$. This is simple enough to do by hand (pull out a $\sqrt{x}$ and then define a new variable to be $\frac{y}{x}$, then expand this variable about $0$). But, I cannot figure out how to do it in Mathematica.

EDIT 1

I've since realized that what I actually want to do is more complicated than the example above. Consider the following expression $\sqrt{a+d} + \sqrt{b+d}\;$ expanded for small $\frac{d}{a}$ and small $\frac{d}{b}$ (that is $a>>d$ and $b>>d$). Following Artes' answer below, the solution is

Series[ (a + d)^(1/2) + (b + d)^(1/2) /. {d -> z1 a, d -> z2}, {z1, 0, 2},{z2, 0, 2}] /. 
{z1 -> d/a, z2 -> d/b}

But this solution doesn't work as intended due to the order operations Mathematica performs upon this command. What needs to be done is to replace d with z1 a, then expand z1 about 0, replace z1 with d/a, then replace d with z2 b, expand z2 about 0, and finally replace z2 with d/b. How can one do this in Mathematica?
(Obviously the example I gave can be separated into two expressions when can be expanded separately, but this cannot be done for the more complicated expression I am actually trying to expand).

$\endgroup$
2
  • $\begingroup$ If this example can be simply worked out as you've observed then it won't be an appropriate one to present the issue. Try to provide another example which might be better suited for your real problem. You shouldn't use 0.5 since it means (in Mathematica) a machine precission number unlike 1/2 denoting an exact value. $\endgroup$
    – Artes
    Jun 27, 2013 at 17:30
  • $\begingroup$ From a mathematical point of view, this is a possible duplicate of Multivariable Taylor expansion does not work as expected. There are some practical differences, but I think they are very minor. $\endgroup$
    – Jens
    Jun 28, 2013 at 0:47

1 Answer 1

8
$\begingroup$

There are options in Series (Analytic, Assumptions) which you might exploit. Nonetheless let's use a bit more straightforward approach, simply change the variable y (y -> z x) and then back z -> y/x:

Series[(x + y)^(1/2) /. y -> z x, {z, 0, 5}] /. z -> y/x // Quiet // TraditionalForm

enter image description here

Edit

Since the question has been edited we should add a few remarks.
In order to transform appropriately the Series results (its head is SeriesData) we should get rid of it with Normal (then we loose terms with powers (y/x)), e.g.

Normal @ Series[(x + y)^(1/2) /. y -> z x, {z, 0, 5}] /. z -> y/x // TraditionalForm

enter image description here

Nonetheless we can transform appropriately expressions of the form (a + d)^(1/2) + (b + d)^(1/2) working with SeriesData if we define a simple function, e.g.

f[x_, y_, k_] := Series[(x + y)^k /. y -> z x, {z, 0, 5}] /. z -> y/x

(a + d)^(1/2) + (b + d)^(1/2) /. (x_ + y_)^k_ -> f[x, y, k] // Quiet // TraditionalForm

enter image description here

Alternatively we can expand a given expression around infinity, e.g.

Series[(a + d)^(1/2) + (b + d)^(1/2) /. {a -> v d, b -> w d},
       {v, Infinity, 5}, {w, Infinity, 5}] /.
{v -> a/ d, w -> b/d} // Quiet // TraditionalForm
$\endgroup$
10
  • $\begingroup$ much simpler than what I use, +1. $\endgroup$
    – rcollyer
    Jun 27, 2013 at 15:03
  • $\begingroup$ Ah, this makes sense. What if I have many ratio's I want to expand about? My expression is a function of a,b,c,d,e,f and I want to write it as an expansion for d,e,f << a,b,c. Is it valid to use ReplaceAll in steps? That is, first replace d with d/a, expand, then replace d with d/b, expand, etc... for each d,e,f. I could do this with a loop, obviously, but each Series expansion is already slow enough. Is there a way to do it using a similar method as your answer above? $\endgroup$
    – mcFreid
    Jun 27, 2013 at 15:14
  • $\begingroup$ @rcollyer Thanks for an upvote. $\endgroup$
    – Artes
    Jun 27, 2013 at 15:18
  • $\begingroup$ @mcFreid You could use just once ReplaceAll e.g. Series[...]/.{z1->d/a,z2->e/b,z3->f/c} and then change variables back. There are in 99% cases better ways than loops in Mathematica. $\endgroup$
    – Artes
    Jun 27, 2013 at 15:22
  • $\begingroup$ So there's no issue with Series[expr /. {d -> z1 a, d -> z2 b, d -> z3 c, e -> z4 a, e -> z5 b, e -> z6 c, f -> z7 a, f -> z8 b, f -> z9 c}] /. {z1 -> d/a, z2 -> d/b, etc...} ? $\endgroup$
    – mcFreid
    Jun 27, 2013 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.