3
$\begingroup$

The title says it all. Reading posts such as this however, I'm not seeing how to do this. This is the simplest example that can show my problem.

f = c/x;
a = a1;
b = b1;
NIntegrate[f, {x, a, b}] /. {a1 -> 1, b1 -> 4, c -> 2}
$\endgroup$

3 Answers 3

4
$\begingroup$

You just have to make the substitution in both the function and limits before NIntegrate. Simple example:

f = c/x;
NIntegrate[f /. #, {x, a, b} /. #] & @ {a -> 1, b -> 4, c -> 2}
$\endgroup$
3
$\begingroup$

Holding NIntegrate Unevaluted also works.

Unevaluated[NIntegrate[f, {x, a, b}]] /. {a -> 1, b -> 4, f -> 2/x}
(* 2.77259 *)
$\endgroup$
2
$\begingroup$

Maybe little odd method:

g[f, {x, a, b}] /. {a1 -> 1, b1 -> 4, c -> 2, g -> NIntegrate}
$\endgroup$

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.