I'm currently trying to introduce myself to some programming with Mathematica. I'm not the most familiar with programming in general, but I work best by just trying to make stuff.
In this code, I'm trying to make a Riemann sum. I know that the Riemann sum function exists, but I want to try to make it myself. So far here is what I have.
taylorintegral[Demand_, Lower_, Upper_] :=
Module[{x},
Δxintegral = (Upper - Lower)/n;
xistar = Lower + Δxintegral*i;
Limit[Sum[Demand[xistar]*Δxintegral, {i, 1, n}], n -> ∞]]
Now, if I say run the following
taylorintegral[x^2, 1, 3]
The output I receive is,
Limit[Sum[(2*(x^2)[1 + (2*i)/n])/n, {i, 1, n}], n -> Infinity]
Where it didn't actually plug in the xistar value in for x^2.
How do I define the module so that it reads the demanded function and then evaluates the demanded function at xistar within the Limit[Sum[...]] code?
x^2is not a function and therefore can't take anything as input. You can input a pure function to your function like this:taylorintegral[#^2 &, 1, 3]– Anjan Kumar May 11 '17 at 01:16