Question 2: [10 points] The impedance of a certain RLC electrical circuit is giv
ID: 3911560 • Letter: Q
Question
Question 2: [10 points] The impedance of a certain RLC electrical circuit is given by: where resistance R = 225 ohms, capacitance C = 0.6 × 10-6 F, and inductance L = 0.5 H Write a computer program that uses Bisection Method, and calculates the angular frequency ? that results in an impedance of Z= 75 ohms. Use bracket of 1 and 1000 Continue the iterations until ?? falls below the pre-specified criteria of, 0·1% Note: See figure 5.11 or slides for the pseudocode of Bisection Method Show the following results in the output for each iteration: ? ?)xf a),Explanation / Answer
----------------------------------f.m--------------------------
function [x] = f(w)
R = 225;
C = 0.6 * ( 10 ^ -6 );
L = 0.5;
Z = 75;
x = sqrt( ( 1 / ( R ^ 2 ) ) + ( ( w * C - ( 1 / ( w * L ) ) ) ^ 2 ) ) - ( 1 / Z );
end
--------------------------------------bisection.m-------------------------------
% calculate f(1)
f_1 = f(1);
% calculate f(1000)
f_1000 = f(1000);
fprintf('f(1) : %f f(1000) : %f ' , f_1 , f_1000);
% if root exists
if f_1 * f_1000 < 0
% get the root between 0 and 1
a = 1;
b = 1000;
% find root upto 0.1% error
error = 0.1 / 100;
% store the previous root
pre = 0.0;
% calculate the current root
x = ( a + b ) / 2;
% infinite loop
while true
% if the root is correct upto n decimal places
if abs( x - pre ) <= error
break;
end
% calculate the value of function
f_x = f(x);
if f(a) >= 0 && f(b) < 0
% if the value of functon at x is positive
% root lies in range [ a , x ]
if f_x > 0
a = x;
% if the value of functon at x is negative
% root lies in range [ x , b ]
else
b = x;
end
else
% if the value of functon at x is negative
% root lies in range [ x , b ]
if f_x > 0
b = x;
% if the value of functon at x is positive
% root lies in range [ a , x ]
else
a = x;
end
end
% set the current root as the previous root
pre = x;
% calcualte the new root by calculating the mid value
x = ( a + b ) / 2;
end
fprintf('Root lies at x = %f ' , x);
% if root doesn't exist
else
fprintf('As the sign of f(0) and f(2) is same. SO, no root exists between [0 , 1] ');
end
Sample Output
f(1) : 1.986671
f(1000) : -0.008674
Root lies at x = 157.908326
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.