00:00

in this episode you’ll learn how to find the average value of a continuous

function on a closed interval let’s do some math [Music]

hi everyone welcome back we’re going to start off with the question what is the

average value that a continuous function f takes on over an interval a b

so to do this um we’re going to start looking at what a continuous

function on a closed interval so we have something like this right here we have

some kind of continuous function and we have some kind of closed interval

right here and so i’ll just draw a generic function

and a generic closed interval it could be like 1 4 2 3 you know just any closed

interval any continuous function right here and we want to talk about the

average value now you have some kind of intuition

00:01

about what this word right here means especially if you’re in a math course or

or in some kind of class right because you may be taking some um exams or

something like that and like if you take

like three exams for example and they’re all equally weighted

then you can try to find your exam average so let’s say you take three

exams and those are your grades and then you divide by three and then you’ll see

that your average exam grade would be a 75 at that point right there

so this is you know some intuition about what the average value means

but this isn’t the case where you have a finite number of values like you have

three exams or you have even if it’s a hundred or a thousand but

a finite number of them you just add up all of them and then you divide by how

many of them you have so it’s just an elementary idea of of average but what

if you have a continuous function and now when you you look at a b here

and you look at your continuous function

00:02

right here and we’re going to be talking about infinitely many values right in

here and for each one we can go up and find a height so this would be if you

just pick an arbitrary x this would be the f of x right here that would be the

height right there and so if you look at all those heights

you how would you find the average if you have infinitely many points right if

you just have a finite number of points we can just add up all of the um f of

x’s all the outputs and then divide by however many uh of them we have

right and so that’s the idea here so if we take a continuous function

uh we’ll sample a finite number of values so let’s say i have x1 x2 x3

and let’s just say i have say in fact let’s just call them cs to

represent that we’re sampling so let’s just call this one here ck

and then this height right up here would be f of ck

and we could just add them all up and so k represents the

00:03

um the index so c1 c2 c3 and so on and so we have a finite number of them

and then in that case we can sampling of them is is the same as

dividing up the interval a b into um in sub intervals right so k is going

from you know one all the way to n and we’re going to get all these intervals

here all these little tiny tiny intervals and we can add up all the um

function heights right here um and so you know that’s exactly what

we’re going to do here is we’re going to be adding up all of these function

height the heights the outputs and then dividing by the n and this would give us

a average value here now you know each of these

sub intervals right here so we have a ck chosen right here

and we go up and we compute the height here uh f of c k

and so you know we have these um sub intervals right here and the width

00:04

of each sub interval right here the delta x here

right so so the whole a b is like way out here like here’s an a and here’s a b

right and so we’re going to have all these little sub intervals in here

and you know each each of them has width because we look at the whole thing b

minus a that’s the whole distance of the interval right here and divide it up by

an equal number of them so um so this is all the delta x’s have

the same width right here so you know we can divide by this in here

and when we put it in this form right here what we can do is we can use uh

summation notation and just say from 1 to n

and then the cks right so k is the the index right here

and then we just have one over n and now what i’m going to do is i’m

going to substitute over here and get this delta x and bring the delta x into

the problem so 1 over n right so you know

just multiply both sides by b b minus a and you get one over n

00:05

and so that’ll be delta x um and then b b minus a down here and so

now i’m going to bring the delta x in here and the reason why i do that is

bringing the delta x in here is so that now we can

uh realize that this hey this right here

looks um is is looks just like a riemann sum right here and so this would be one

over b minus a times this riemann sum right here

and so if we let n go to infinity and we’re going to be taking uh

infinitely many uh sampling points here infinitely many infinitely many of them

and past the limit if possible and we’re

kind of addressing this by assuming that the function is continuous

and you know we’re going to have the following definition right so we’re

going to integrate or we’re going to pass the limit um and then we’ll have

the average value of a function as the limit right here in the limit

right here and when we have the limit right here since this is a constant we

00:06

can bring the limit inside right here and then we have the limit of the

riemann sum and the limit of the riemann sum right there is just the um you know

the integral right there the definite integral right there and the left-hand

side that limit um we’re calling that the

average value so this is the definition of the average value

is this right here this this integral right here so

i guess i can move out of the way real quick it’s just denoted by so i’m going

to use an av of f and it’s just going to be called the

average value of a continuous function if it’s continuous then we’re going to

be good to go and so let’s look at an example now so

find the average value of a function right here

now when i do this right here when i try to find the average value of this

function right here now first i’m going to actually

00:07

use different words right here i’m going to say find and approximate

approximation find an approximation to the to the average value so i’m going to

replace the word v with find an approximation to the average value

so an approximation means you know it’s not unique you can have any kind of

approximation you want but you know how do you actually approximate the average

value first i’m going to try to address address that before we find the average

value the meaning the unique one which is of course the exact one so um yeah

let’s look at a python notebook real quick and let’s go to that so

let’s zoom in here a little bit now if you’ve never used python before

um i recommend checking out the link below in the description

where you can see how to use the python notebook and

so we’re going to use this right here python notebook and the link below is is

00:08

free it’s totally free and you don’t have to

use python you can just follow along if you want but if you are um

using the notebook and following along then i’m going to import these packages

right here numpy and matplot and scipy and actually i’m not going to actually

even use this last one here you don’t need to import this last one here if you

don’t want to now i am going to make some plots so if

you watched any of these episodes before you know that i like to customize my

plots right there by the way let me just take a moment to

say that this episode is part of the series applications of integration

complete in-depth tutorials for calculus so the link below to the full series is

below in the description all right and so yeah i’m going to

customize my axes and then i’m actually going to click up this plot function

right here real quick so let me execute that

and all right so we got that set up in there um i’m gonna um make up this plot

00:09

function here we’re gonna input a function a minimum value and a maximum value

and we’re gonna define some axes customize axes and i’m going to plot

like a thousand points for x and then input them into the

function and then show that plot right there all right so there’s those that’s

a setup right there let’s minimize that now let’s look at our first example here

so this was the example that we’re looking at right here where it says find

the average value of the function on the integral on the interval here

now let’s suppose we don’t know how to find the average value in other words we

don’t know the calculus part let’s just see how we do this by hand if we were

insistent upon trying to find the average value

so first thing i’m going to do is type in this function right here now this is

the function that’s given to us as f of x and it’s example one so i’m just going

to call the function f1 i’m defining a new function of x

and the function is just 3 and then times x squared and then minus 3. so

let’s just execute that function and now

00:10

we have f1 and it’s very easy to plug in numbers into f1 we can plug in one half

we can plug in one-third or 0.3 and then we can do

outputs you know actually get outputs now let’s go ahead and try to look at an

average value right here so i’m going to start at zero i’m going to plug in zero

into the function right here and i’m going to go all the way to 1 i’m going

to plug in 1 into the function right here

but i’m going to choose some numbers in between so i’m going to do some sampling

so 0.25 0.3 0.67 0.83 and 1. and i just chose those randomly and i’m going to

plug each of those into the function f1 and i’m going to add them all up and

then i’m going to divide by how many of them i have and so this would give us an

approximation to the average value right

here that’s not the average value that’s just an approximation

now to be more um you know to do a lot more points besides six so now i’m going

to cook up a function right here so i’m going to call this function here

00:11

approximate average value i’m going to input a function

for example here’s a function right here i’m going to input an a to b

0 1 and i’m going to input a and n and so we’ll be able to you know take as

an input however many we’re going to do and so we’re just going to say x is the

chosen and we’re going to chose them equally spaced and we’re going to choose

n of them and then we’re going to return the sum of all the outputs

and so we’re going to put all these x’s into them if n is 6 then we’ll put all

of them in we’ll add them all up and then we’ll divide by that in so let’s

execute that cell right there so this will be an approximate average value

right here so i’m going to run this on this function right here so here’s f1

that’s the function we defined here here’s 0 1 here’s 6.

and let’s run this approximate average value function right here

now you notice i got a little bit of a different answer and the reason why is

00:12

because when we execute this code right here

we’re choosing equally spaced in our sampling here i just chose random ones

and so we’re not going to get necessarily the same value right there

if you just choose random ones compared to equally spaced so

let’s just take a look at the function what it is f1 on this interval here zero

to one here it is and it looks like i’m getting average

value of something like negative 1.8 negative 1.9

which is about like right here so if we look at all the output heights

and we average them all up and we’re getting something pretty close to

negative 2 right there just for the approximations

all right so now let’s go back to the math and

let’s see here let’s see actually how to do this

using calculus now let’s find the average value the exact value

so what we’re going to do is we’re going to say a of f the average value

00:13

is equal to and so we’re going to have 1 over b

minus a so it’s going to be 1 minus and then we’re going to integrate 0 to 1

and then we’re going to integrate the function here 3x squared minus 3

and then dx and then so yeah we’re just going to

evaluate this integral right here so this integral right here

is just that’s all just 1 and so we’re integrating 0 to 1 of 3x

squared minus 3. in fact i’m just going to pull the 3 out here and just say

integral of x squared minus 1 dx and so this will be x to the third over three

minus x and then integrate this zero to one

and then now let’s come in here with the one so we’re gonna get three times

uh one third minus one and then when i substitute in zero it all vanishes

and so it looks like we’re getting here this is think of this as three over

00:14

three so this is minus minus two thirds and so the 3s cancel we end up with

minus 2. so the average value of this function right here over this interval was

exactly minus 2. so here’s the calculus to find the average value and this is

not sampling this is not doing an approximation this is doing infinitely

many of them and so yeah calculus is really powerful

there really quick and easy to find the average value

all right so let’s look at another example example two here and let’s go here

and look at this function right here now f of x is three x squared minus two x

and we’re gonna be looking over the interval one four

um and so yeah we can find the average value real quick

but i really want to drive home that um that um of how you approximate it

and so i want to find the average value of this function over this interval but

00:15

i actually want to approximate it i want to just get an approximate value

and you know the reason why this is valuable is because even though you may

technically be able to say that an integral exists it may be a different

thing entirely to actually evaluate it so this is still has um lots of value in

here um but i’m going to define the function

so 3x squared and then i’m going to say minus 2x

and then i’m going to just you know do some inputs and outputs i’m going to add

up all the all these right here and so i’m going from one to four so i’m just

choosing one 1.25 and then a 2.3 3.67 so i’m just sampling between one and four

and i’m just adding them all up so let’s execute these cells here

let’s uh shift enter in there and then let’s go down here and hit shift enter

very good so we get an approximation to the average value right here it’s about

20.645 and so yeah we can do this again here and

00:16

let’s do say 600 you know what how long would it take to do 600 of them

right so if you had to approximate and you know it’s very easy

to do lots of them really fast uh okay yeah so here we did did it in

again right here all right so let’s take a look at the

plot of this function right here f2 on interval one to four and so we can see

the uh approximate the average value is close to 16. so 16 is about right here

so that’s about the average value of the outputs all right so

um yeah so then now let’s go find the actual um exact value right there

so find the average value of this function over the interval right here

so the average value will be and we’re going to go

it’s going to be 1 over b minus a so 4 minus 3 sorry 4 minus 1

00:17

and then integral from 1 to 4 and then we’re going to integrate

integrate this function right here and yeah so now we can get 1 3

and we can integrate this right here this will be

3 times x to the third over three and then minus two and then this will be

x squared over two and i’m going to go one to four

and so yeah without boring you you get 48 over three or 16

and that is the exact value right there so very good so

there’s the exact average value right there all right so let’s just ask this

question now if this is the average value according to our tuition which we

believe it is if the average value really is a typical value of the integral

of the integrable function then the average value should have the

00:18

same integral over a b that f does and so let’s actually show that that’s

actually true and so the way i’m going to do that is

i’m going to say the average value of f which is 1 over b minus a integral from

a to b of f of x and i’m going to call that a constant

just to make this a little bit easier to write out now

why is this a constant well of course it’s a constant the average value is a

number right so you integrate with respect to x you do

um you know the anti-derivative at b minus you know a

at a and then you know you multiply by this number right here so this is a

number right here so i’m just going to call this k

so that’s a constant right there so let’s see if we can start with the left

and get to the right and let’s see how to do that here so let’s go a to b

and average value of f and now like i said this is just a k

00:19

it’s just a constant after you go find it

it may be hard to find or maybe easy to find whatever it is to find you found it

it’s a number let’s move that number outside of the integral

and then this is just dx here now the integral from a to b of dx is

just well it’s just x a to b or in other words b minus a here

all right so we can find this integral right here it’s just this it’s just k

times it looks like i used a capital k so i should be consistent there

um all right and so this right here uh k here

um let’s substitute back in now what the k is remember k is all of this

so let’s write that for k so instead of using k here i’m going to

write all this out again so 1 over b minus a integral a to b f of x dx

so that’s just the k right there and then all that times b minus a so

00:20

i’ll just put big brackets there just to make it look clear

and so the b minus a’s here actually cancel

and so we just get the integral from a to b of f of x so if you

integrate the average value it’s just the same thing as integrating the

function right there f of x all right so that’s just kind of a

maybe you want to call it a sanity check or something i don’t know

all right so how can we use this how can we use this average value here so let’s

use it to do something interesting here so

let’s say we’re taking the temperature um in a room or somewhere and we want to

take the temperature so let’s look at temperature and we want to do this for

24 hours so we’re going to take the temperature every hour on the hour

00:21

and so what we can do is we can say that we have f of x one star

plus f of x two star and we’re gonna do this here

um n times and n is twenty four so we’re gonna so basically every hour on the

hours think of the x1 star as let’s say you started at midnight and then that

would be one o’clock you’d and then the function f is take the temperature right

so that means at one o’clock you take the temperature so that right there is

representing the temperature at one o’clock and then here’s the temperature at

two o’clock and then so on for 24 hours and then

we’re going to divide by this in here and so we can get the average

temperature right here and so what we can do is we can write

this as 1 1 over b minus a and then integral of or not integral but sum

00:22

of the f of x let’s use a k k [Music] k equals 1 to n and get the delta x here

so just as we did before this is going to be an approximation to the average

value this is a the average value and if you’re if you’re discrete a

finite number of choices write every hour on the hour then we can write it

like this right here and so yeah if we take the limit as n

goes to infinity then we’ll get the um exact value and we’ll get the

integral over here for example what if you wanted to take

the temperature not every hour but what if you wanted to take it every 30

minutes right so then then this would be

many more and you would have a different larger end right and so if you want to

go every um every minute or actually every second

so how would you actually find the right the limiting value right there

right so you would have the average value of f

and so this would be the same as taking the temperature

at every instant in time whatever that would mean

00:23

and that would be this average value of the function right there

all right and so um um let’s say we’re going to try to do

something with it mathematically and we can

um you know instead of thinking about the temperature we can ask a question like

um so remember at the beginning when i talked about what if you have three

three exam grades and they’re all equally weighted and you want to try to

find your exam average and so in this case right here the exam average is what

225 over 3 or in other words 75 and so here’s an example where one of

the exam grades was actually equal to the exam average so

if you have a finite number of of choices though um that that may be

00:24

not happening right so what if you have say a 51 and a 76 or how about a 74

we would still have the 225 over 3 we would still have 75 but now it happened

that you didn’t actually make a 75 on the exam

so you know if you have a continuous function though if you’re doing

infinitely many of these and trying to find the average value of

a continuous function so then you can try to ask the question

is there always an input where the output is equal to the average value

um and so that’s the question right there is um and the answer to that is

called the mean value theorem for integrals

and it states that if f is continuous on a closed interval a b

so that’s exactly the the condition that we have to define the average value

00:25

so then there exists so this is an existence theorem then there exists

a number c in a b in this inside the interval here um so b is you know

greater than or equal to a less than or equal to b such that

f of c is equal to the average value so we’ll just say the average value

average value of f which we know is one minus one over b minus a of integral

from a to b of f of x so it’s saying that there is an input in

which the average value so the examples that we’re looking at the average

temperature or the average grade um the average value

there was some input that hit that average value

so that doesn’t necessarily happen to hap have to happen for the discontinuous

00:26

or the discrete case but for continuous functions there has to exist a c

that is equal to the average value now sometimes you might want to rewrite

it sometimes you might want to say integral a to b f of x dx

is equal to so i’m just going to multiply both sides by b minus a so just

move the b minus a up here and we’ll get f of c times b minus a

and so that’s a kind of a nice slick way there

saying that if f is continuous on a closed interval right here a b

then there exists a c such that the output times b minus a the length of

the interval here that’s actually really nice to know because

what that tells us is that something that may be difficult to compute

remember this is the limit of riemann sum

you know for a large number of functions that you can integrate and you may be

able to actually find an anti-derivative and actually come up with this number

right here pretty easily but for a large number of functions it may be difficult

00:27

but this right hand side looks like you just substitute in c into the function

right so this is actually very handy not

only just because it looks so pretty and nice but actually you can use this in a

lot of different theorems to prove more interesting results all right so

let’s look at an example of this right here how can we

use this an example right here so let’s look at a quick example before we go

here so um we’re going to say f of x is one plus x squared

and we’re looking on the interval minus one to two and so let’s just actually

find the average value of this rule really quick so what’s the average value

of this function right here on minus one to two

so it’s going to be one over and then it’s going to be two minus a negative

one and then we’re going to integrate from minus one to two of one plus x

squared dx and so yeah this is just what 1 3

00:28

and so we’re going to integrate here from minus 1 to 2 1 plus x squared right

so we’re going to be integrating the one we’re just going to get an x and we’re

going to integrate the x squared so x to the third over 3

and then we’re going to go from -1 to 2 and long story short when you integrate

this out plug in all the numbers simplify you get 2. so the average value of f

on this interval right here is just 2. now what is the mean value theorem for

integral say it says that the integral from -1 to two of f of x dx is equal to

f of c times two minus the negative one which we know is three so it says that

let’s just write a three right we already talked about that that’s three

so three times f of c so we can actually find the c so the mean

00:29

value theorem says there exists a c where this equation is true but actually

because we have a concrete function and we’re able to find the actual

average value so now we can actually go and find out what this is right here so

the average value right here is is one third integral of all this we found the

average value is just a two and what happens when you plug in the f of c

so the f of c is one plus c squared and so yeah just looking at this you can

see what the c is so this implies that c is equal to now

just because we’re solving this equation you have to take into account the over

the uh starting interval right here because we’re only looking on this

interval right here but both both c’s actually work right minus 1 and 1

are both in here so c is plus or minus 1. so the mean value theorem says there

has to exist a c for this to hold but actually sometimes you can actually go

and find those c’s and this in this example here there are actually two c’s

00:30

that actually make the mean value theorem for integrals work

all right so i hope you enjoyed this video and uh have a great day and i’ll

see you in the next episode if you enjoyed this video please like

and subscribe to my channel and click the bell icon to get new video updates