Lab12 - % DAVID REYES, UC Berkeley, SID 18973480, E7, HW...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
%% DAVID REYES, UC Berkeley, SID 18973480, E7, HW 12, Fall08, Section 22 %% Problem 1 %% Problem 1a pdf_w=@(x) x*(1/8); min_w=2; max_w=10; mu_w=quad(pdf_w,min_w,max_w); disp(mu_w) %% int=@(x) (x-mu_w).^2*(1/8); var_w=quad(int,min_w,max_w); sigma_w=sqrt(abs(var_w)); disp(sigma_w) %% Problem 1b mu_L_w=10000*mu_w; sigma_L=sqrt(10000*sigma_w^2); disp(mu_L_w) disp(sigma_L) %% Problem 1c L = sum(8*rand(500,10000)+2,2); %% mu_L=mean(L); std_L=std(L); L_bar=sum(L)/500; sigma_bar=sum((L-L_bar).^2)/500; disp(mu_L) disp(L_bar) disp(std_L) disp(sigma_bar) %% [PDF x]=my_PDF(L,20); bar(x,PDF) hold on gauss = @(x) gaussian(x,mu_L,std_L); plot(x,gauss(x)) hold off %% Problem 1d % P(x>=60400) P=0.5-quad(gauss,mu_L,60400); disp(P) P2=0.5*erfc((60400-mu_L)/(std_L*sqrt(2))); disp(P2) %% Problem 2 fucntion myTrapIntegrator clear all %% Problem 2a type myTrapIntegrator %% I1=@(x) cos(x)+sqrt(x); format long myTrapIntegrator(I1,0,(pi/2),101) format short %% Problem 2b I_bar=myTrapIntegrator(I1,0,(pi/2),101); error=@(N) abs((I_bar-myTrapIntegrator(I1,0,(pi/2),N))/I_bar); N=[6 11 21 51 101 151 251 501 1001]; trap=zeros(1,length(N)); for i=1:length(N); trap(i)=error(N(i)); end
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
%% Problem 2c I2= @(x) exp(-x.^2); eval=quad(I2,-2,2); format long disp(eval) eval2=myTrapIntegrator(I2,-2,2,501); disp(eval2) format short %% Problem 2d function myTrapIntTol type myTrapIntTol %% % I2 with tol 10^-5 myTrapIntTol(I2,-2,2,10^-5) % I2 with tol 10^-12 myTrapIntTol(I2,-2,2,10^-12) %% I3=@(x) (sin(x)).^2+exp(cos(x)); % I3 with tol 10^-2 myTrapIntTol(I3,-2,2,10^-2) % I3 with tol 10^-10 myTrapIntTol(I3,-2,2,10^-10) %% Problem 3 clear all
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/18/2010 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at Berkeley.

Page1 / 6

Lab12 - % DAVID REYES, UC Berkeley, SID 18973480, E7, HW...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online