9
$\begingroup$

I have discovered a very inconvenient behaviour of SeriesData in a new version of Mathematica v12.3.0: it automatically expands brackets in the series coefficients!

Example: For the input

SeriesData[z,0, {l^2 ((2 a + b) x + (a + 2 b) y) + 1/2 l^2 Log[z], 0}, 0, 2, 1]

Mathematica, for the unknown reason, returns the following answer:

1/2 (4 a l^2 x + 2 b l^2 x + 2 a l^2 y + 4 b l^2 y + l^2 Log[z]) + O(z^2)

This is very annoying since I had written quite a lot of commands that took the coefficients apart, simplified according to some rules, and then constructed the SeriesData object back.

Is it possible to turn this automatic expansion off?

P.S. An even better example is the following:

ClearAll[a,b,z];
SeriesData[z,0, {(a+b)^50+Log[z], 0}, 0, 2, 1]

The output will have this $(a+b)^{50}$ bracket expanded. Neither Simplify nor FullSimplify applied to the series will factorize the result.

P.P.S. The SeriesData works correctly with fractional powers. P.P.P.S. I received a confirmation from Wolfram that this is a bug:

"Hello Sergei, Thank you for contacting Wolfram Technical Support. I understand that SeriesData automatically expands brackets in the series coefficients if logarithms are present. I have passed it to the relevant people in our development team so this can be considered for future versions of Mathematica. We are always interested in improving Wolfram products, and I want to thank you once again for bringing this issue to our attention. If you run into any other problems with any of our products, please do not hesitate to contact us.

Regards, Wolfram Technical Support

Wolfram Research Inc. https://support.wolfram.com"

$\endgroup$
6
  • 2
    $\begingroup$ The result you see is just how SeriesData formats, see the second bullet point in the Details section of the SeriesData doc page. Try running InputForm[%] after evaluating your SeriesData[...] input. $\endgroup$
    – Jason B.
    Oct 29, 2021 at 19:35
  • $\begingroup$ @JasonB. I am not sure that I understand your comment. What I want to get is l^2 ((2 a + b) x + (a + 2 b) y) + 1/2 l^2 Log[z] + O(z^2) instead of the mess it gives me. Furthermore, imagine that instead of one of the brackets $(a+2b)$ in the input we had something like $(a+2b)^{70}$. The Mathematica will literally expand this huge bracket! $\endgroup$
    – Ovserger
    Oct 29, 2021 at 19:46
  • $\begingroup$ Finally, neither Simplify nor FullSimplify commands will simplify these expressions $\endgroup$
    – Ovserger
    Oct 29, 2021 at 19:49
  • 1
    $\begingroup$ This is indeed new behavior. For example, version 10.2 did not behave this way. $\endgroup$
    – Somos
    Oct 29, 2021 at 23:49
  • 1
    $\begingroup$ Why not just replace the terms you don't want with a Symbol to represent it? That's the easy, standard way to handle this thing. You can't always expect to avoid expansion when working with a CAS $\endgroup$
    – b3m2a1
    Oct 30, 2021 at 0:04

1 Answer 1

6
$\begingroup$

As a workaround, you may wish to use a display function to show the SeriesData object in a simplified form. Using the examples in the question,

ClearAll[a, b, z, s1, s2];
s1 = SeriesData[z, 
   0, {l^2 ((2 a + b) x + (a + 2 b) y) + 1/2 l^2 Log[z], 0}, 0, 2, 
   1];
s2 = SeriesData[z, 0, {(a + b)^50 + Log[z], 0}, 0, 2, 1];

Such a function could be

Clear[display]
display[expr_] := Simplify /@ (Normal[expr] + (expr - Normal[expr]))

display[s1]  
display[s2] 

enter image description here

The trick is to use Normal to isolate the big-O term from the part to be simplified

$\endgroup$
1
  • $\begingroup$ Thank you, this is a nice and neat workaround for displaying series. Manipulating series, however, is still an open problem. I will try to contact Wolfram support $\endgroup$
    – Ovserger
    Oct 30, 2021 at 10:54

Your Answer

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

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