MATLAB: How to calculate the area under a curve

areacalculuscurveintegralstan(x)under

Hi, I'm struggling with this when the upper limit of integration is a function itself.
The question is as follows:
"Calculate the area confined by the functions f(x)=x+3 and g(x)=tan(x) in the first positive interval. From x=0 to the first positive intersection point (where f(x)= g(x))."
Thanks for any help.

Best Answer

The upper limit is not a function, you just have to find where tan(x) is equal to x+3, so your limits of integration are [0, tan(x)=x+3]. You can find this numerically with
uplim = fzero(@(x) tan(x)-x-3,1.2)
Why did I pick 1.2? Because tan(x) "blows up" at pi/2 because cos(pi/2) is zero (the denominator), accordingly, if you look for a zero too close to that discontinuity, you're going to get a bad result.
You can test that the answer return by fzero() is good
tan(uplim)-uplim-3
Now you know the upper limit of integration.
Related Question