5
$\begingroup$

So, I'm new to Mathematica. I tried evaluating the following definite integral. However the answer i get from wolfram alpha & mathematica are different. Can someone please point out what I'm missing? The answer from wolframAlpha is correct according to Casio fx-991-es

Integrate[1/(1 + t) ((t + 0.8)/(t + 1))^20, {t, -0.8, 0}]

enter image description here

enter image description here

$\endgroup$
2
  • $\begingroup$ Please paste copy&pastable code instead of screenshots. It is not fair to the people who are trying to assist to make them need to retype all your content based on some images. $\endgroup$
    – ktm
    Commented Sep 9, 2018 at 1:43
  • $\begingroup$ oh I'm sorry Integrate[1/(1 + t) ((t + 0.8)/(t + 1))^20, {t, -0.8, 0}] $\endgroup$ Commented Sep 9, 2018 at 1:45

1 Answer 1

8
$\begingroup$

Precision issues. Use one of the following instead.

Symbolic integration:

Integrate[(1/(1 + t)) ((t + 4/5)/(t + 1))^20, {t, -4/5, 0}]
(*-(318650448087859023644/198221683502197265625) + Log[5]*)

N@%
(*0.00189205*)

Numeric integration with a higher working precision:

NIntegrate[(1/(1 + t)) ((t + .8`20)/(t + 1))^20, {t, -.8`20, 0}]
(*0.00189205*)
$\endgroup$
8
  • $\begingroup$ Usually when do these issues occur? should i use NIntegrate instead? $\endgroup$ Commented Sep 9, 2018 at 1:52
  • $\begingroup$ These issues appear when machine precision numbers are insufficient for the precision needed to accurately compute what you require. $\endgroup$
    – ktm
    Commented Sep 9, 2018 at 1:54
  • $\begingroup$ There's a ton of doc pages on these topics. Here's another useful one: Control the Precision and Accuracy of Numerical Results $\endgroup$
    – ktm
    Commented Sep 9, 2018 at 1:55
  • $\begingroup$ Appreciate your help 🙌Thanks! $\endgroup$ Commented Sep 9, 2018 at 1:57
  • 1
    $\begingroup$ @RamithHettiarachchi -- (1) Note further that if you do just add an N in front of your Integrate[..], you get the same answer as the NIntegrate[..] in this post. Higher precision is unnecessary in the numerical integrator. (2) Symbolic solvers such as Integrate often have trouble with "inexact" floating-point input. (3) Interesting aside: Integrate[(1/(1 + t)) ((t + .8`20)/(t + 1))^20, {t, -.8`20, 0}] caused my kernel to crash! So even with high-precision approximate inputs, exact solvers may still have problems. $\endgroup$
    – Michael E2
    Commented Sep 9, 2018 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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