# Differentiation and series expansion of dot product - inconsistent results

Bug introduced in 9.0 or earlier and persisting through 11.3 or later

Bug resolved in 12.0

As of 12.0, we have an unevaluated result - inconsistent with the differentiation result, but not invalid.

SeriesCoefficient[a.b[x], {x, 0, 1}]
(* SeriesCoefficient[a.b[x], {x, 0, 1}] *)


If I differentiate a dot product, I get the result I expect

D[a.b[x], x]
(* a.b'[x] *)


However, a series expansion of the same expression (V9-V11) gives a very different result

SeriesCoefficient[a.b[x], {x, 0, 1}]
(* a.1 b'[0] *)


Is there any logical explanation of this behaviour?

EDIT

This has been confirmed as a bug by Wolfram support.

• attempts to work with abstract vectors in mathematica are usually not fruitful. Note that second strange result can never be evaluated since Dot with a integer is not defined – george2079 Jun 24 '16 at 15:03
• bug present in 11.1.0 – user58955 Mar 24 '17 at 1:11
• I think the "edit" part should be in the answer, not the question. – user202729 Aug 7 '18 at 1:52
• I don't think this is a bug. One might regard it as a limitation that Series was not designed (or implemented) to work with Dot. But that in and of itself is not a bug. – Daniel Lichtblau Aug 7 '18 at 13:27
• @DanielLichtblau - If Mathematica returns an expression unevaluated, that isn't a bug. If it returns a result that I don't expect, but has a reasonable and logical explanation, that isn't a bug. Here, Mathematica has evaluated a reasonable input and returned a result that nobody has argued is logically correct. Therefore (as the email I had from Wolfram support agreed) I classify it as a bug. – mikado Aug 7 '18 at 19:21

This has been confirmed as a bug by Wolfram support.

(Bug still present in 11.0.0)

You can muck about with an internal function to get Series to work a bit better on Dot (and Cross etc) products. For example:

protect = Unprotect[SystemPrivateInternalSeries];
SystemPrivateInternalSeries[a_Dot, {x_, x0_, n_Integer?NonNegative}] := Module[
{d = NestList[D[#, x]&, a, n], res},

res = Quiet @ Check[d /. x->x0, $Failed]; SeriesData[x, x0, TensorExpand @ res, 0, n+1, 1] /; res =!=$Failed
]
Protect @@ protect;


SeriesCoefficient[a.b[x],{x,0,1}]


a.b'[0]

A more complicated example:

Series[Exp[a[x].b[x]+x^2], {x, 0, 2}] //TeXForm


$e^{a(0).b(0)}+x e^{a(0).b(0)} \left(a'(0).b(0)+a(0).b'(0)\right)+\frac{1}{2} x^2 e^{a(0).b(0)} \left(\left(a'(0).b(0)+a(0).b'(0)\right)^2+2 \left(a''(0).b(0)+2 a'(0).b'(0)+a(0).b''(0)+1\right)\right)+O\left(x^3\right)$

Where this modification won't help is when the series is not a Taylor or MacLaurin series, e.g., a Laurent or Puiseaux series.