To find the area of the shaded region, we have to find the area between the two curves \(y = sin(x) + 1\) and \(y = sin(x)\):
\(f_1(x) = sin(x) + 1\)
\(f_2(x) = sin(x)\)
\(area_1 = \int_{0}^{\pi}f_1(x) dx\)
\(area_2 = \int_{0}^{\pi}f_2(x) dx\)
\(area = area_1 - area_2\)
\(area = \int_{0}^{\pi}f_1(x) dx - \int_{0}^{\pi}f_2(x) dx\)
\(area = \int_{0}^{\pi} (f_1(x) - f_2(x)) dx\)
\(area = \int_{0}^{\pi} (sin(x) + 1 - sin(x)) dx\)
\(area = \int_{0}^{\pi} (1) dx\)
\(area = x \vert_{0}^{\pi} = \pi - 0\)
\(area = \pi = 3.141593\)
#Find area in-build function
f1 = function(x) {sin(x) + 1}
f2 = function(x) {sin(x)}
#Find the difference between areas under the curve
area1 <- integrate(f1, 0, pi)
area2 <- integrate(f2, 0, pi)
area <- (area1$value - area2$value)
print(c(area1$value, area2$value))
## [1] 5.141593 2.000000
print(area)
## [1] 3.141593
To find the area of the shaded region, we have to find the area between the two curves \(y = 4^x\) and \(y = 2^x\):
\(f_3(x) = 4^x\)
\(f_4(x) = 2^x\)
\(area_3 = \int_{0}^{1}f_3(x) dx\)
\(area_4 = \int_{0}^{1}f_4(x) dx\)
\(area = area_3 - area_4\)
\(area = \int_{0}^{1}f_3(x) dx - \int_{0}^{1}f_4(x) dx\)
\(area = \int_{0}^{1} (f_3(x) - f_4(x)) dx\)
\(area = \int_{0}^{1} (4^x - 2^x) dx\)
\(area = (\frac{4^x}{ln(4)}-\frac{2^x}{ln(2)}+C) \vert_{0}^{1}\)
\(area = (\frac{4^1}{ln(4)}-\frac{2^1}{ln(2)}+C) - (\frac{4^0}{ln(4)}-\frac{2^0}{ln(2)}+C)\)
\(area = (\frac{4}{ln(4)}-\frac{1}{ln(4)}+C-\frac{2}{ln(2)}+\frac{1}{ln(2)}-C)\)
\(area = (\frac{3}{ln(4)}-\frac{1}{ln(2)})\)
\(area = (2.16404256 - 1.44269504)\)
\(area = 0.72134752\)
#Find area in-build function
f3 = function(x) {4^x}
f4 = function(x) {2^x}
#Find the difference between areas under the curve
area3 <- integrate(f3, 0, 1)
area4 <- integrate(f4, 0, 1)
area <- (area3$value - area4$value)
print(c(area3$value, area4$value))
## [1] 2.164043 1.442695
print(area)
## [1] 0.7213475