ClearAll;
$DefaultFont = {"Times-Roman",10};
Needs["Statistics`DataManipulation`"];
Needs["Graphics`Graphics`"];
njags = 100;
text1 = Graphics[Text["0",{-0.03,0}]];
text2 = Graphics[Text["x",{1.03,0}]];
text3g = Graphics[Text["g",{0,0.088}]];
text3h = Graphics[Text["h",{0,0.088}]];
text3gplh = Graphics[Text["g+h",{0,0.088}]];
text3hplg = Graphics[Text["h+g",{0,0.088}]];
text4 = Graphics[Text["a",{0.27,-0.009}]];
text5 = Graphics[Text["c",{0.51,-0.009}]];
text6 = Graphics[Text["b",{0.79,-0.009}]];
axesx = Graphics[Line[{{0,0},{1,0}}]];
axesy = Graphics[Line[{{0,0},{0,0.08}}]];
zero[x_]:= 0;
g[x_]:= 0.1 - x^2(1-0.9x)^2;
h[x_]:= x^2(1-x)^2 + 0.02;
sum[x_]:= g[x] + h[x];

poly[a_,b_,v_,w_]:= Polygon[Join[Table[{a+i(b-a)/njags,v[a+i(b-a)/njags]},
				  {i,0,njags}],
				  Reverse[Table[{a+i(b-a)/njags,w[a+i(b-a)/njags]},
				  {i,0,njags}]]]];
shade[a_,b_,c_,v_,w_]:= Graphics[{GrayLevel[c],poly[a,b,v,w]}];
	 


graph1 = Graphics[Plot[g[x],{x,0,0.9}]];
fill1 = {shade[0.27,0.79,0.35,zero,g],shade[0.27,0.79,1.0,g,sum]};
plot1 = Show[axesx,axesy,text1,text2,text3g,text4,text6,
		fill1,graph1];
		
graph2 = Graphics[Plot[h[x],{x,0,0.9}]];
fill2 = {shade[0.27,0.79,0.65,zero,h],shade[0.27,0.79,1.0,h,sum]};
plot2 = Show[axesx,axesy,text1,text2,text3h,text4,text6,
		fill2,graph2];

graph3 = Graphics[Plot[sum[x],{x,0,0.9}]];
fill3 = {shade[0.27,0.79,0.35,zero,g],shade[0.27,0.79,0.65,g,sum]};
plot3 = Show[axesx,axesy,text1,text2,text3gplh,text4,text6,
		fill3,graph3];
		
graph4 = Graphics[Plot[sum[x],{x,0,0.9}]];
fill4 = {shade[0.27,0.79,0.65,zero,h],shade[0.27,0.79,0.35,h,sum]};
plot4 = Show[axesx,axesy,text1,text2,text3hplg,text4,text6,
		fill4,graph4];

			
Show[GraphicsArray[{{plot1, plot2},{plot3, plot4}}],
	PlotLabel->"                                     Figure 9.3\n\n
	Area(g,[a,b]) + Area(h,[a,b]) = Area(g+h,[a,b]) = Area(h+g,[a,b])"]