---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
# Let's calculate the area of the circle sector depicted below on the left
BF=3; HF=3
PLANE(0,5,0,5)
f=function(x) sqrt(25-x^2); g=function(x) 3/4*x
graph1(f,-5,5,"blue"); graph1(g,-5,5,"blue")
graph(f,4,5,"red"); graph(g,0,4,"red"); segm(0,0, 5,0, "red")
 
# This is the figure. It is a circle segment. I can take the circle area multiplied by
# the ratio between the angle of the segment and 360:
 
A=c(5,0); B=c(0,0); C=c(4,3); angle(A,B,C)
# 36.8699
pi*5^2*angle(A,B,C)/360
# 8.043764        This is the searched area
 
# Alternatively, I calculate the area of the triangle and that of the remaining part
# where the figure is broken by the vertical segment falling from (4,3)
 
polyl(c(4,4),c(0,3),"blue")
# The area of the triangle plus the integral of f between 4 and 5:
4*3/2 + integral(f,4,5)
# 8.043764
  
 
# Let's calculate the area of the figure above, in the center:
 
PLANE(0,1, 0,1)
f=function(x) x^2; g=function(x) x
graph(f,0,1, "blue"); graph(g,0,1,"red")
 
# The difference between the area under the graph of g and the one below that of f:
 
integral(g,0,1)-integral(f,0,1)
# 0.1666667
# Or:
h = function(x) g(x)-h(x); integral(h,0,1)
# 0.1666667      which is equivalent to:
fraction(integral(h,0,1))
# 1/6    This is the searched area
#
# The area of the figure above, on the right, between the two curves:
 
PLANE(0,4,-2,2)
f = function(x) sin(x); g = function(x) (x-2)^2
graph(f,0,4, "red"); graph(g,0,4, "blue")
solution2(f,g,1,2)
# 1.064761
solution2(f,g,2,3)
# 2.67242
h = function(x) f(x)-g(x)
integral(h, solution2(f,g,1,2), solution2(f,g,2,3))
# 1.002636   This is the searched area
# just over a "square"