Question
You will need octave for this. there are 4 parameters the user is asked for. For the report, you are expected to keep 3 of
You will need octave for this.
there are 4 parameters the user is asked for. For the report, you are expected to keep 3 of the constant, and vary only n. I recommend using Q = 1, and a = d = 1.
Q1 solution is below.
clear all close all
%finding integration using trapizoidal ruke and finding the error %the upper limit is x=10; %integral using trapizoidal rule for different n n=[3 5 10 15 25 30 50 150 200];
%loop for calculating trapizoidal integral fprintf('Table for finding the integral result ') for i=1:length(n) val(i)=trapizoidal(x,n(i)); err(i)=abs(val(i)-1); fprintf('\t For n=%d \t relative error=%2.2e ',n(i),err(i)) end
%plotting the result semilogy(n,err) xlabel('n') ylabel('Relative error') title('step size vs. error plot using Trapizoidal rule')
%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %%Matlab function for trapizoidal integration function val=trapizoidal(x,n) % func is the function for integration func=@(x1) (1./sqrt(2*pi)).*exp((-x1.^2)/2); % a is the lower limit of integration a=-10; % b is the upper limit of integration b=x; % n number of rectangles to be used val=0; %splits interval a to b into n+1 subintervals xx=linspace(a,b,n+1); dx=xx(2)-xx(1); %x interval %loop for trapizoidal integration for i=2:length(xx)-1 xx1=xx(i); val=val+dx*double(func(xx1)); end val=val+dx*(0.5*double(func(xx(1)))+0.5*double(func(xx(end)))); end %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%
2. In the configuration below, find the electric potential of the uniformly charged square plane of length a and charge Q at point P (these parameters should be entered by the user as "input"). To do so, you should divide the plane into nxn pieces (let the user define n, using the function "input") and evaluate the electric potential of each piece at point P, then add them all together. Note that the electric potential is a scalar and is defined by: da V= i=1 The distance between each little square of charge dq and point P, ri, should be taken from the center of the little square and point P. Front view of the plane of charge Side view dg For your report: try several values of n (including, but not limited to, n= [1, 3, 10, 30, 100], give a table of the values of n and the result, and plot the result of V vs n (you can use semilog or a linear plot, I leave that to your discretion) 2. In the configuration below, find the electric potential of the uniformly charged square plane of length a and charge Q at point P (these parameters should be entered by the user as "input"). To do so, you should divide the plane into nxn pieces (let the user define n, using the function "input") and evaluate the electric potential of each piece at point P, then add them all together. Note that the electric potential is a scalar and is defined by: da V= i=1 The distance between each little square of charge dq and point P, ri, should be taken from the center of the little square and point P. Front view of the plane of charge Side view dg For your report: try several values of n (including, but not limited to, n= [1, 3, 10, 30, 100], give a table of the values of n and the result, and plot the result of V vs n (you can use semilog or a linear plot, I leave that to your discretion)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started