# How to quickly calculate the limit of integral with parameters

I want to quickly calculate the limit value of $$\lim _{x \rightarrow 0} \frac{\int_{0}^{x} t \ln (1+t \sin t) d t}{1-\cos x^{2}}$$.

But using the code below I need to take 40 seconds to get the result:

Limit[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]),
x -> 0]


I get an error message if I use the numerical method to solve:

Needs["NumericalCalculus"]
NumericalCalculusNLimit[
Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]), x -> 0]


What should I do to get the correct limit value quickly?

• Series[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]), {x, 0, 1}] // Normal Aug 9 '20 at 3:38

\$Version

(* "12.1.1 for Mac OS X x86 (64-bit) (June 19, 2020)" *)

Clear["Global*"]

f[x_?NumericQ] :=
NIntegrate[t*Log[1 + t*Sin[t]], {t, 0, x},
WorkingPrecision -> 25]/(1 - Cos[x^2]);

Plot[f[x], {x, 10^-9, 1/100},
PlotPoints -> 100,
MaxRecursion -> 5,
PlotRange -> All,
WorkingPrecision -> 25] // Quiet


The order of the next two operations affects the relative times

Series[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]), {x, 0, 1}] //
Normal // AbsoluteTiming

(* {24.254, 1/2} *)

Limit[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]),
x -> 0] // AbsoluteTiming

(* {54.4468, 1/2} *)


Starting with a fresh kernel and reversing the order

Clear["Global*"]

Limit[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]),
x -> 0] // AbsoluteTiming

(* {72.6784, 1/2} *)

Series[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]), {x, 0, 1}] //
Normal // AbsoluteTiming

(* {5.99999, 1/2} *)

• Use Clear["Global  * "] twice (before Series[] too). to obtain correct timings. Aug 9 '20 at 5:25

L'Hôpital's rule needs ~10% of the calculation time

Normal[Series[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]  , {x, 0, 4}]]/Normal[Series[(1 - Cos[x^2])  , {x, 0, 4}]]
(* 1/2*)
`
• This is very nicely done. Aug 9 '20 at 14:16
• @J.M. Thanks! A good occasion to show this rule dated 1694. Aug 9 '20 at 19:40