I need to generate a Pade approximant expansion in v
of the following:
$$g(x,v)\equiv \ln\int_{-\infty}^{\infty}e^{-y\left(z\right)}N\left(x-z,v\right)\,\mathrm{d}z $$
where $y(x)\equiv\sum_{i=1}^{n}c_{i}x^{i}$, $n$ is even, and $c_{n}>0$ so the integral converges. $N(x,v)$ is the PDF of the Normal distribution in $x$ with variance $v$. I can generate derivatives of $g[x,v]$ wrt $v$ using the following relations, which arise from properties of the Normal:
$$\frac{dg[x,v]}{dv}=\frac{1}{2}\frac{d^{2}g}{dx^{2}}+\frac{1}{2}\left(\frac{dg}{dx}\right)^{2}$$
$$g[x,0]=y(x)$$
This code implements the above relations:
ord = 5;
Derivative[q_, 1][g][x_, v_] =
D[(D[g[x, v], {x, 2}] + D[g[x, v], x]^2), {x, q}]/2;
h = Table[D[g[x, v], {v, i}], {i, 0, ord - 1}];
y[x_] := Sum[c[i]*x^i, {i, 0, 4}];
dgdv =
Expand[h /. Derivative[q_, 0][g][x, v] -> D[y[x], {x, q}] /. g[x, v] -> y[x]]
But Series doesn't work:
Series[g[x, v], {v, 0, 2}]
$\qquad g(x,0)+v g^{(0,1)}(x,0)+\frac{1}{2} v^2 g^{(0,2)}(x,0)+O\left(v^3\right)$
and I couldn't figure out how to get pattern matching to complete the result:
Series[g[x, v], {v, 0, 2}] /.
Derivative[q_, r_][g][x, v] ->
D[(D[g[x, v], {x, 2}] + D[g[x, v], x]^2), {x, q}, {v, r - 1}]/2
gives the same result as the foregoing.
I can cope with Series
not working because that's easy to hack around, but what I really want to generate is the Pade approximant of g[x, v]
in v
, but that's more complicated to hack around.
I realize I could just take the PadeApproximant of a Taylor series generated with my hack code, but that doesn't sound look good practice.
Any ideas?
Edit
I think Series
or PadeApproximant
might work if I could create a definition of the derivative that works on 2nd derivative wrt v and higher. It's not an issue in my code above because Mathematica seems to just be applying my 1st derivative definition repeatedly. But Series
doesn't seem to know to do that, and I can't figure out how to define the derivative w.r.t higher orders of v
without causing a recursion problem. I'm posting that as a separate Question
Derivative[q_, 1][g][x_, v_] := D[(D[g[x, v], {x, 2}] + D[g[x, v], x]^2), {x, q}]/2;
and it works. Note the change toSetDelayed
, too, as it generally is what you want, but it makes no difference here. $\endgroup$SeriesData[v, 0, { g[x, 0], Rational[1, 2] ( Derivative[1, 0][g][x, 0]^2 + Derivative[2, 0][g][x, 0]), Rational[1, 2] Derivative[0, 2][g][x, 0]}, 0, 3, 1]
what do you get? $\endgroup$Normal
on theSeriesData
givesg[x, 0] + (1/2)*v^2*Derivative[0, 2][g][x, 0] + (1/2)*v*(Derivative[1, 0][g][x, 0]^2 + Derivative[2, 0][g][x, 0])
which means it did use theDerivative
you specified. $\endgroup$