3

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}
user1543042
  • 385
  • 1
  • 8

3 Answers3

4

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}
Bichoy
  • 1,203
  • 6
  • 15
3

Holding NIntegrate Unevaluted also works.

Unevaluated[NIntegrate[f, {x, a, b}]] /. {a -> 1, b -> 4, f -> 2/x}
(* 2.77259 *)
bbgodfrey
  • 61,439
  • 17
  • 89
  • 156
2

Maybe little odd method:

g[f, {x, a, b}] /. {a1 -> 1, b1 -> 4, c -> 2, g -> NIntegrate}
Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78