It has been years since calc 2 but if I remember correctly the $\int$ calculates the area under a curve. I have some code that is approximating the area under a given function by calculating the values at an interval then averaging those values and multiplying by the x. I'm trying to improve the performance and accuracy.
The basic function is:
$1-e^{\frac{x}{1000}}$
Graphing this produces a curve that is bounded at y at 1. So the area under this function should be $<$ $x$
Ok to the math and hopefully someone sees the basic mistake I must be making (basically calculating the area between $|_0^{100}$
$\int_0^{100} (1-e^{\frac{-x}{1000}}) $
$\int_0^{100} 1 - \int_0^{100}e^{\frac{-x}{1000}}$
$x |_0^{100} - \int_0^{100}e^{\frac{-1}{1000}*x}$
$100 - \frac{-1000}{1} e^{\frac{-x}{1000}}|_0^{100} $
$100 + 1000 *e^{\frac{-x}{1000}} |_0^{100}$
$100 + 1000 * (e^{\frac{-100}{1000}} - e^0)$
$100 + 1000 * (e^{\frac{-1}{10}} - 1) $
$100 + 1000 * (.9048 -1) $ (1.01 - 1) (Fixed)
$100 + 1000 * -.09516 $
$100 + -95.16$
$4.8374$
And this seems very wrong! (FIXED!)
I believe the answer should be about $\approx 4.829$
Thanks for looking at this!
I see three errors in this:
$\text{Error 1:}$
$$\int1\ dx=x+c\ne1+c$$
So we should have
$$\int_0^{100}1\ dx=\left.x\vphantom{\cfrac11}\right|_0^{100}=100$$
but somehow this hasn't actually affected the answer, since you end up with $100$ anyways.
$\text{Error 2:}$
$$\int_0^{100}e^{-x/1000}dx\ne-1000\int_0^{100}e^{-x/1000}dx$$
This appears around the spot where you try to evaluate the integral. However, again, you come to the correct end result, leaving us with error 3...
$\text{Error 3:}$
$$e^{-1/10}=0.904837419\ne1.105171$$
It appears you forgot to make the negative sign in the exponent come into play. Once you put this in, everything should be fine.