︠abbc19bf-031d-4d29-ab2f-080c7da19b1ei︠ %html

Definite Integrals

This notebook will help you with the following:

︡5c09705c-a3b1-406b-97e9-7acbb7a9ea8e︡{"html": "

Definite Integrals

\n

This notebook will help you with the following:

\n"}︡ ︠ad474c91-45ab-4195-878d-85f1d8b35a20︠ #auto var('x,y,t') ︡4d74189e-bf8c-4255-8efe-f5baa08b4d10︡{"stdout": "(x, y, t)"}︡ ︠1b05ea7f-8a40-404f-a6fc-bce21a1837b2i︠ %html

Approximating Area

If you enter a function, a range of $x$ values from $a$ to $b$, and a number $n$ of rectangles you want to create, the code below will compute both left and right endpoint approximations to the directed area under $f$.  I said directed because if $a>b$, then you will get a negative, and if $f<0$ then you will get a negative as well.

︡d46806f9-7252-4175-b0f4-e76326810cad︡{"html": "

Approximating Area

\n

If you enter a function, a range of $x$ values from $a$ to $b$, and a number $n$ of rectangles you want to create, the code below will compute both left and right endpoint approximations to the directed area under $f$.  I said directed because if $a>b$, then you will get a negative, and if $f<0$ then you will get a negative as well.

"}︡ ︠3ce11ebe-a314-4f36-9ffd-f46c3dd7a76b︠ f(x)=4-x^2 a=0 b=2 n=4 dx=(b-a)/n xvalues=[(a+k*dx) for k in range(0,n+1)] yvalues=[f(c) for c in xvalues] dAvalues=[f(c)*dx for c in xvalues] p=plot(f,a,b) for k in range(0,n+1): p+=point((xvalues[k],yvalues[k]),rgbcolor='black') p+=line([(xvalues[k],0),(xvalues[k],yvalues[k])],rgbcolor='black') for k in range(1,n+1): p+=polygon([(xvalues[k]-dx,0),(xvalues[k]-dx,yvalues[k]),(xvalues[k],yvalues[k]),(xvalues[k],0)],rgbcolor=(1,0,0),alpha=.2) p+=polygon([(xvalues[k-1]+dx,0),(xvalues[k-1]+dx,yvalues[k-1]),(xvalues[k-1],yvalues[k-1]),(xvalues[k-1],0)],rgbcolor=(0,0,1),alpha=.2) leftsum=sum([dAvalues[k] for k in range(0,n)]) rightsum=sum([dAvalues[k] for k in range(1,n+1)]) xvalues.insert(0,"x") yvalues.insert(0,"y") dAvalues.insert(0,"dA = y dx") html.table([ xvalues,yvalues,dAvalues ]) p.show() html.table([ ["Left Sum",leftsum,leftsum.n()], ["Right Sum",rightsum,rightsum.n()], ["Average Sum",(leftsum+rightsum)/2,((leftsum+rightsum)/2).n()], ["Actual Area",integrate(f,a,b),integrate(f,a,b).n()] ]) ︡b88ab58d-5574-4a0b-98f8-d556d18e1226︡{"html": "\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
x0\\frac{1}{2}1\\frac{3}{2}2
y4\\frac{15}{4}3\\frac{7}{4}0
dA = y dx2\\frac{15}{8}\\frac{3}{2}\\frac{7}{8}0
\n
\n"}︡{"html": ""}︡{"html": "\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Left Sum\\frac{25}{4}6.25000000000000
Right Sum\\frac{17}{4}4.25000000000000
Average Sum\\frac{21}{4}5.25000000000000
Actual Area\\frac{16}{3}5.33333333333333
\n
\n"}︡ ︠e8eaf2c4-107c-4738-83e9-e3e6e4c76460i︠ %html

Definite Integrals $\displaystyle \int_a^b f(x) dx$

The following code will compute definite integrals, as well as graph a function and shade the region between the function and the $x$-axis.

You can type in your functions using $t$, $x$, or any other variable you wish.

︡e96a0b3d-bb5c-4ce9-99a2-4f87fa15d3e9︡{"html": "

Definite Integrals $\\displaystyle \\int_a^b f(x) dx$

\n

The following code will compute definite integrals, as well as graph a function and shade the region between the function and the $x$-axis.

\n\n

You can type in your functions using $t$, $x$, or any other variable you wish.

"}︡ ︠d9727ca0-1054-4f99-a5da-58ff6780e291︠ v(t)= 4-t^2 a=0 b=5 p=plot(v,a,b,fill=true).show() integrate(v,a,b) ︡5a8cebfb-d8aa-44bf-80c5-fe3f13e4ae83︡{"html": ""}︡{"stdout": "-65/3"}︡ ︠ed615ee4-61b7-4128-9313-0e0267cb0639i︠ %html

Area between $f$ and the $x$-axis.

If you want to find the area between $f$ and the $x$-axis, the first step is to find the zeros of the function. Then you break the integral to integrate over positive and negative parts separately.  The code below will find the zeros, give you the integral, tell you the area from both the positive and negative parts, as well as the total area.

︡e0596da8-243e-4e50-9c96-0e2afc64f260︡{"html": "

Area between $f$ and the $x$-axis.

\n

If you want to find the area between $f$ and the $x$-axis, the first step is to find the zeros of the function. Then you break the integral to integrate over positive and negative parts separately.  The code below will find the zeros, give you the integral, tell you the area from both the positive and negative parts, as well as the total area.

"}︡ ︠5af96e10-4f68-4b0a-8be4-1ec1caa6ec9d︠ f(x) = x^2-x-6 a=-5 b=5 x_intercepts = solve(f,x) p=plot(f,a,b,fill=true) DI=integrate(abs(f(x)),a,b) g=abs(f) Area=g.nintegrate(x,a,b) PA=((g+f)/2).nintegrate(x,a,b) NA=((g-f)/2).nintegrate(x,a,b) html.table([ ["x intercepts", x_intercepts], ["Integral of f", integrate(f(x),x)], ["Total Area", Area[0]], ["Positive Area", PA[0]], ["Negative Area", NA[0]], ]) p.show() ︡3b896fac-ba81-463b-8522-bb343ae96ff7︡{"html": "\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
x intercepts\\text{[\nx == 3,\nx == -2\n]}
Integral of f\\frac{1}{3} \\, x^{3} - \\frac{1}{2} \\, x^{2} - 6 \\, x
Total Area65.0
Positive Area44.1666666667
Negative Area20.8333333333
\n
\n"}︡{"html": ""}︡ ︠14f87079-ed25-4211-aed6-d5b8f2ff370di︠ %html

Average Value $\displaystyle \frac{1}{b-a}\int_a^b f(x)\ dx$

The code below computes the average value of a function. Remember that the average value of a continuous function always passes through the function.  The average value $AV$ is the $y$ value so that the area above $AV$ below $f$ is the same as the area below $AV$ and above $f$. I like to think of average value as the height of sand in an ant farm that would result from shaking the ant farm to make a level top.

︡207698dc-a51c-46d7-9915-29e5c0485929︡{"html": "

Average Value $\\displaystyle \\frac{1}{b-a}\\int_a^b f(x)\\ dx$

\n

The code below computes the average value of a function. Remember that the average value of a continuous function always passes through the function.  The average value $AV$ is the $y$ value so that the area above $AV$ below $f$ is the same as the area below $AV$ and above $f$. I like to think of average value as the height of sand in an ant farm that would result from shaking the ant farm to make a level top.

"}︡ ︠602360f5-21ed-4454-8b89-d8c854646573︠ f(x) = 4-x^2 a=0 b=2 average_value = 1/(b-a)*integrate(f,a,b) sols=solve(f(x)==average_value,x) html.table([ ["Average Value", average_value], ["x values", sols], ]) p=plot(f,a,b,fill=true,fillalpha=.2,fillcolor='red') p+=plot(average_value,a,b,fill=true,fillalpha=.2,fillcolor='blue',color='black') p.show() html.table([["Notice how the area above the average value is the same as the area below."]]) ︡d9b4b0f7-ea6a-486a-8d9b-9ed62472b528︡{"html": "\n
\n\n\n\n\n\n\n\n\n\n\n\n
Average Value\\frac{8}{3}
x values\\text{[\nx == -2/3*sqrt(3),\nx == 2/3*sqrt(3)\n]}
\n
\n"}︡{"html": ""}︡{"html": "\n
\n\n\n\n\n\n\n
Notice how the area above the average value is the same as the area below.
\n
\n"}︡