0
$\begingroup$

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`"]
NumericalCalculus`NLimit[
 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?

$\endgroup$
1
  • 2
    $\begingroup$ Series[Integrate[t*Log[1 + t*Sin[t]], {t, 0, x}]/(1 - Cos[x^2]), {x, 0, 1}] // Normal $\endgroup$
    – Bob Hanlon
    Aug 9 '20 at 3:38
2
$\begingroup$
$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

enter image description here

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} *)
$\endgroup$
1
  • $\begingroup$ Use Clear["Global ` * "] twice (before Series[] too). to obtain correct timings. $\endgroup$
    – user64494
    Aug 9 '20 at 5:25
3
$\begingroup$

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*)
$\endgroup$
2
  • $\begingroup$ This is very nicely done. $\endgroup$
    – J. M.'s torpor
    Aug 9 '20 at 14:16
  • $\begingroup$ @J.M. Thanks! A good occasion to show this rule dated 1694. $\endgroup$ Aug 9 '20 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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