Using Kirchoff's law an equation can be derived representing the relationship between angular frequency (w) and impedance (z). The RLC circuit can be pictured on the left, where the resistor is set in series with the inductor and capacitor. These circuits are commonly used in electronics as filters for frequency.
Equation (1) describes the impedance (z) given resistance (R),
The function above is made by setting equation 1 equal to zero.
The equation can be put directly on Desmos's graphing calculator seen above. Seeing the plot can help with setting estimation boundaries, especially when using closed methods.
The bisection method estimates by creating an estimate right in the middle of the two boundaries. These boundaries change depending on where the new estimate lies in relation to the function.
The false position method estimates a line given two points of the function. Where this line passes 0 is where the new estimate will be.
%%problem 1 Krichoff
%Juan Parra
%set parameters
R = 225;
C = .6*10^-6;
L = .5;
w = 1:1000;%create for function (1-1000)
z = 75;
f = (w)*1 ./(sqrt( 1 /R^2 + (w .*C - 1 ./w*L) .^2)) - z;
plot (f,w)
% Bisection method
xl = 1;
xu = 1000;
xrn = xu;
xro = xl;
%set parameter for initial guesses
for i = 1:1:1000
xro = xr;
xr = (xl + xu)/2;
xrn = xr;
%set up xr for if statement
if (f(xl) * f(xr)) < 0
% array is getting nonlogical values
% function is not being used
xu = xr;
else
xl = xr;
end
Br = f(xr);
%error
Be = abs( (xrn - xro)/ xrn) ;
end
% False Position
fpxl= 1;
fpxu = 1000;
fprn = fpxu;
fpxro = fpxl;
for i = 1:1:1000
fpxr = fpxu - ((f(fpxu)*(fpxl-fpxu)/ f(fpxl)-f(fpxu)));
fprn = fpxr
if (f(fpxl)*f(fpxr))< 0
fpxu = fpxr
else
fpxl = fpxr
end
end
The bisection arrived much faster to the solution than the false position method, since the false position had very little change per iteration.
The error was calculated based on its difference from its previous estimate. The Bisection error stayed somewhat constant, the high values come from how the new xr is derived. The false position error did stay consistent per iteration.
When looking for a closed method the curve of the graph can have a serious impact on the number of iterations it might take. In this problem, the false position method did not work as well as it could have. The curve's shape slowed down the false position since the estimation works best when a curve has a steep slope.
Regarding Matlab I had issues plotting my function along with merging the function to the estimations. I tried adding my function at the end so that my closed methods worked. I also tried switching my function to a handle function but had no succes.