To find the area bounded by two curves fx=2cos(x) and gx=-2sin(2x) on the interval from x=0 to x=2, we can use calculus and MATLAB's integral
function.
Firstly, we need to find the intersection points of the two curves within the given interval. We can set fx and gx equal to each other and solve for x:
2cos(x) = -2sin(2x)
cos(x) = -sin(2x)
cos(x) = -2sin(x)cos(x)
Since cos(x) cannot be zero within the given interval, we can divide both sides by cos(x):
1 = -2sin(x)
sin(x) = -0.5
We can use MATLAB's fzero
function to solve for the two roots within the interval [0,2]:
main.m70 chars4 lines
Now we can define a new function that gives the difference between fx and gx:
main.m48 chars2 lines
And finally, we can use the integral
function to find the area between the two curves:
main.m28 chars2 lines
The resulting area
should be around 1.4386.
Here is the full code:
main.m147 chars7 lines
gistlibby LogSnag