> # Unbounded integrands # # Here we consider examples in which the integrands are unbounded. The justifications for the choices of gauges are found in the file unbounded.pdf > restart: > with(plots): Warning, the name changecoords has been redefined > read("khtools.m"); # Example 1. # > f1:=proc(x) > local f: > if x=0 then f:=0; > else f:=-ln(abs(x)); > end if: > end: > d1:=proc(x) > local d1: > if x=0 then d1:=epsilon: > else d1:=abs(x)*(exp(epsilon)-1)/(exp(epsilon)+1): > end if: > end: > epsilon:=0.12; epsilon := 0.12 > khbox(f1,-1,1,d1,y=0..5); The Riemann sum is 1.250355 > # Example 2. # > f2:=proc(x) > local f2: > if (x=0) then f2:=0; > else f2:=1/(abs(x))^(1/2): > end if: > end: > d2:=proc(x) > local d2: > if (x=0) then d2:=epsilon2: > else d2:=epsilon2*abs(x): > end if: > end: > epsilon2:=0.1: > khbox(f2,0,2,d2,y=0..4); The Riemann sum is 2.226162 > khbox(f2,-1/2,1/2,d2,y=0..4); The Riemann sum is 1.557272 # Example 3. > > f3:=x->piecewise(x<=-1,0.1,x<1,1/sqrt(1-x^2),0.1); / 1 \ f3 := x -> piecewise|x <= -1, 0.1, x < 1, ------------, 0.1| | / 2\ | \ sqrt\1 - x / / > d3:=proc(x) > local d3; > if abs(1-abs(x))>0 then d3:=epsilon3*abs(1-abs(x)); > else d3:=epsilon; > end if; > end: > epsilon3:=0.09; epsilon3 := 0.09 > khbox(f3,-1,1,d3,y=0..2); The Riemann sum is 2.177344 > # Example 4. # > f4:=x->piecewise(x<=-1,0,x<0,2*(1+x)^(-1/2)-(-x)^(-1/2),x=0,0,x<1,(1-x)^(-1/2)-x^(-1/2),x=1,0); / 2 1 f4 := x -> piecewise|x <= -1, 0, x < 0, ------------ - ---------, x = 0, 0, | (1/2) (1/2) \ (1 + x) (-x) 1 1 \ x < 1, ------------ - ------, x = 1, 0| (1/2) (1/2) | (1 - x) x / > > epsilon4:=0.1; epsilon4 := 0.1 > > d4:=x->epsilon4*(min(abs(x),1-abs(x))+floor(x+1)-ceil(x)); d4 := x -> epsilon4 (min(|x|, 1 - |x|) + floor(1 + x) - ceil(x)) > khbox(f4,-1,1,d4,y=-2.5..5.5); The Riemann sum is 1.280994 > >