3
$\begingroup$

I have a question about the "Series" command. Specifically, the following input

Series[Sqrt[x^2], {x, 0, 2}]

gives me the following output

x+O[x]^3.

However, we know that this is not true for some $x$, e.g. for $x<0$. Because of the singular derivative at $x=0$, I would have expected Mathematica to give an error of some kind here. Moreover, when adding an assumption like this

Series[Sqrt[x^2], {x, 0, 2}, Assumptions -> (x < 0)],

I still get the same output

x+O[x]^3,

whereas I know that the leading order should be $-x$ rather than $x$.

I am trying to understand why Mathematica gives me this result. Does "Series" somehow make some general assumptions about the variable of the expansion?

EDIT: I am using Mathematica version 10.2.

$\endgroup$
  • 1
    $\begingroup$ OK in Mma 11.1.0.0: the output under the assumption $x<0$ is $-x+O\left(x^3\right) $. $\endgroup$ – user64494 May 2 '17 at 16:02
  • $\begingroup$ What version are you using? Recent versions appear to give sensible answers. $\endgroup$ – mikado May 2 '17 at 22:19
  • $\begingroup$ Edited the question, I am using version 10.2. Is this is a bug in this version? $\endgroup$ – ScroogeMcDuck May 3 '17 at 10:24
4
$\begingroup$

This is an extended comment to demonstrate the effect of Assumptions in version 11.1.1 While a problem exists in some earlier versions, it has been corrected.

$Version

"11.1.1 for Mac OS X x86 (64-bit) (April 18, 2017)"

Series[Sqrt[x^2], {x, 0, 2}]

enter image description here

Series[Sqrt[x^2], {x, 0, 2}, Assumptions -> (x > 0)]

enter image description here

Series[Sqrt[x^2], {x, 0, 2}, Assumptions -> (x < 0)]

enter image description here

The last two are special cases of

Series[Sqrt[x^2], {x, 0, 2}, Assumptions -> Element[x, Reals]]

enter image description here

$\endgroup$
  • $\begingroup$ This seems more like an output I would have expected. I am using version 10.2, was this a bug in that version? $\endgroup$ – ScroogeMcDuck May 3 '17 at 10:27
  • $\begingroup$ Yes, this appears to be a bug in (some?) earlier versions (e.g., it gives the result shown for x > 0 in all four cases using v10.4.1 on my Mac). $\endgroup$ – Bob Hanlon May 3 '17 at 15:00
  • $\begingroup$ Cool, that's clear then. Could you add to your answer that there's this bug in some earlier versions? I'll accept the answer then since that answers my question $\endgroup$ – ScroogeMcDuck May 8 '17 at 13:04
1
$\begingroup$

Bob Hanlon has shown which solution Mathematica 11.1.1 has determined. We can check it with the Taylor formula.

s = Sum[1/j! Nest[(x - x0)*# &, D[Sqrt[x^2], {x, j}] /. x -> x0, j], {j, 0, 2}]

((x - x0) x0)/Sqrt[x0^2] + Sqrt[x0^2]

Limit[s, x0 -> 0, Direction -> -1]
x

Limit[s, x0 -> 0, Direction -> 1]
-x

Mathematica is right.

$\endgroup$
  • $\begingroup$ I am using version 10.2, which gave me the output in my question. Guess that version was bugged then? The command "Limit" does give the right result in 10.2 as well though. $\endgroup$ – ScroogeMcDuck May 3 '17 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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