3
$\begingroup$

I am having some trouble when trying to evaluate this simple integral using NIntegrate:

NIntegrate[Cos[t + Arg[ (-I + 4 t)]], {t, 0., 1.}]

The error message is

NIntegrate::nlim: t = Arg[-I+4 t] is not a valid limit of integration.

There are ways of avoiding this problem, such as choosing the integration method (Method -> "Trapezoidal".) What is not clear to me is where this error is coming from. If I plot the function being integrated, there is no issue.

Thank you.

$\endgroup$

1 Answer 1

4
$\begingroup$

NIntegrate attempts a bit of symbolic analysis of the integrand before integrating. That seems to be messing something up. Hide your function from symbolic analysis:

f[x_?NumericQ] := Cos[t + Arg[(-I + 4 t)]]
NIntegrate[f[t], {t, 0., 1.}]
(* 0.815624 *)
$\endgroup$
1
  • 2
    $\begingroup$ also NIntegrate[Cos[t + Arg[(-I + 4 t)]], {t, 0., 1.}, Method -> {Automatic, "SymbolicProcessing" -> False}]. $\endgroup$ Aug 3, 2018 at 18:19

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.