Area Between Two Curves
Computing
| > | with(plots): |
Warning, the name changecoords has been redefined
| > | f1:=6+sin(Pi*x); |
| > | f2:=x^2-4*x+6; |
| > | f1Graph:=plot(f1,x=-2..6,y=0..10,thickness=2,color=red): |
| > | f2Graph:=plot(f2,x=-2..6,y=0..10,thickness=2,color=blue): |
| > | display(f1Graph,f2Graph); |
| > | fsolve({f1=f2},{x},x=-1..1); |
| > | fsolve({f1=f2},{x},x=3..5); |
| > | eval(f1,x=0); |
| > | eval(f1,x=4); |
The graphs of the two functions intersect at (0,6) and (4,6).
The area between the two curves is given by the integral below.
| > | Int(f1-f2,x=0..4); |
| > | value(%); |
Below we do some coloring just for fun.
| > | f1Graph2:=plot(f1,x=0..4,thickness=2,color=red,filled=true): |
| > | f2Graph2:=plot(f2,x=0..4,thickness=2,color=blue,filled=true): |
| > | display(f1Graph2); |
| > | display(f2Graph2); |
| > | display(f2Graph2,f1Graph2); |
| > | f2Graph3:=plot(f2,x=0..4,thickness=2,color=white,filled=true): |
| > | display(f2Graph3,f1Graph2); |
| > |