To find the area bounded by the curves f(x) = 9 - c^2 and g(x) = x - 3 in MATLAB, we need to find the intersection points of the two curves first. We can find the intersection points by solving the equation f(x) = g(x), which results in the quadratic equation c^2 + x - 12 = 0. The roots of this equation give us the x-coordinates of the intersection points.
Here's the MATLAB code to find the area:
main.m328 chars8 lines
In the above code, we first declare c and x as symbolic variables using the syms
command. Then we define the two functions f(x) and g(x) using the symbolic variables c and x. Next, we solve the equation f(x) = g(x) using the solve
command, which gives us the x-coordinates of the intersection points. We calculate the corresponding values of c using the equation for the curve f(x). Finally, we use the int
command to calculate the definite integral of the absolute difference between f(x) and g(x) over the interval between the intersection points, which gives us the area bounded by the two curves.
Note that we take the absolute value of the integral because the curve f(x) is below g(x) in the region between the intersection points. Also, we convert the output of the solve
command to double precision using the double
command because the int
command requires numeric input.
gistlibby LogSnag