# Series from an integral and output as a function

I have a simple question, I am just stuck on syntax. I want to have a series of function $$Z(\lambda)=\frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty} d x e^{-\frac{x^2}{2 !}-\frac{\lambda}{4!} x^4}$$ like $$Z_N(\lambda)=\sum_{n=0}^N c_n \lambda^n$$.

And when I type

f[l_] := Integrate[Exp[-x^2/2 - l x^4/24], {x, -Infinity , Infinity}];
g[l, numb_] := Series[f[l], {l, 0, numb}, Assumptions -> {l \[Element] Reals, l > 0}]
g[1,3]


it does nothing.

If I do

f[l_] := Integrate[Exp[-x^2/2 - l x^4/24], {x, -Infinity , Infinity}];
g[numb_] :=  Series[f[l], {l, 0, numb},  Assumptions -> {l \[Element] Reals, l > 0}]


and then try to use the output

% /. l -> 3


It says SeriesData::ssdn: Attempt to evaluate a series at the number 3. Returning Indeterminate. And I can't copy parts of the output and use it as a function.

Can you tell me, how to do it properly? And how I was supposed to take output as a function of l?

Thanks!

• Your code evaluates without problems on Mathematica v12.2/Windows11. Retry with a fresh kernel! Commented Mar 6, 2023 at 16:01
• @UlrichNeumann I tryed at Mathematica 11.3 on Windows 11, it is not working... Commented Mar 6, 2023 at 16:12
• Does v11 evaluate f[l] (*(Sqrt[3] E^((3/4)/l) BesselK[1/4, 3/(4 l)])/Sqrt[l]*) ? Commented Mar 6, 2023 at 16:26

Clear["Global*"]


The integral can be done once

f[l_] = Integrate[Exp[-x^2/2 - l x^4/24], {x, -∞, ∞}]

(* ConditionalExpression[(Sqrt[3] E^((3/4)/l) BesselK[1/4, 3/(4 l)])/Sqrt[l],
Re[l] > 0] *)

g[l_?Positive, numb_Integer?NonNegative] :=
(Series[f[x] // Normal, {x, 0, numb}] // Normal) /. x -> l

g[1, 3] // Simplify

(* (861 Sqrt[π/2])/512 *)

• Thank you very much! I understood that Normal was the main function, that I was missing! Commented Mar 6, 2023 at 23:43

Try

f[l_   ] :=Integrate[Exp[-x^2/2 - l x^4/24], {x, -Infinity, Infinity} ,Assumptions->l>0]


modified:

g[l_, numb_ /; Element[numb, PositiveIntegers]] :=Normal[Series[f[u], {u, 0, numb}]] /. u -> l

g[l,3]


$$\left(\sqrt{2 \pi }-\frac{1}{4} \sqrt{\frac{\pi }{2}}l+\frac{35}{192}\sqrt{\frac{\pi }{2}} l^2-\frac{385 \sqrt{\frac{\pi }{2}}l^3}{1536}+O\left(l^4\right)\right) (-1)^{\left\lfloor \frac{\arg(l)+\pi }{2 \pi }\right\rfloor }$$

g[1,3] (*-((163 Sqrt[\[Pi]/2])/512) + Sqrt[2 \[Pi]]*)

• when I type g[1, 3] it gives the same output g[1, 3]. I definitely don't understand something... Commented Mar 6, 2023 at 16:11
• See my modified answer, hope it helps! Commented Mar 6, 2023 at 16:20
• Dear Ulrich, I appreciate your answer, but I need to evaluate it for specific l, for example, l=0.2. and this is where problems appear. Commented Mar 6, 2023 at 16:31
• why if I write N[g[l, 1]] /. l -> 1 it says that there is an error? Commented Mar 6, 2023 at 16:54
• I confirm that as soon as I try f[z_, numb_] :=Integrate[Exp[-x^2/2]*(Series[Exp[-z x^4/24], {z, 0, numb}] //Normal), {x, -Infinity, Infinity}]; f[0.1, 3] there is a weird error message "General::ivar: 0.1 is not a valid variable." Commented Mar 6, 2023 at 17:21