The problem is that I have to evaluate functions, that take output from previous functions, and combine them to form new functions, and do some operations and evaluate the value at new function.

But, Here is a simple example to demonstrate my problem:

g[x_] := 3 x^2 + 2 x

f[x_] := 20 x + Integrate[g[x], x]


During evaluation of In[146]:= Integrate::ilim: Invalid integration variable or limit(s) in 2. >>

So, as you can see, you get the error, because it tries to evaluate integral with respect to 2 instead of with respect to x.

That means we need to force Integrate function to evaluate w.r.t x, then, it can substitute x = 2. But, how is that possible here?

  • $\begingroup$ define f as f[x_] := 20 x + Integrate[g[y], y] /. y -> x? $\endgroup$ – kglr Mar 19 '15 at 0:03
  • 2
    $\begingroup$ I like f[x_] := 20 x + Integrate[g[y],{y,0,x}] better, as strictly speaking, an indefinite integral isn't really a number or even a function. $\endgroup$ – LLlAMnYP Mar 19 '15 at 0:10

we need to force Integrate function to evaluate w.r.t x

ClearAll[f, g, x]
g[x_] := 3 x^2 + 2 x
f[x_] := Evaluate[20 x + Integrate[g[x], x]]
(* 52 *)
| improve this answer | |
  • $\begingroup$ This seems to work right now. $\endgroup$ – user3330840 Mar 19 '15 at 0:53

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.