Sei sulla pagina 1di 6

Root Finding Methods:

Application to the Behavior of Electrical Circuits


Devyn Kirban
March 5, 2018
Abstract
This paper will discuss how to calculate the resistance needed when designing an electrical
circuit. Specifically, we studied the transient behavior of a closed circuit that consists of a
battery, capacitor, resistor, inductor, and switch.
Introduction
In this paper, we consider the RLC circuit shown in Figure 1 below. We want to find the
resistance required for the circuit. We first combine and derive a few equations that involve each
factor of the circuit. By taking account for the effects of the capacitor, inductor, and resistor, and
applying Kirchhoff’s second law we find a function of resistance. The root of this function is the
desired resistance. To calculate the amount of resistance required to dissipate the circuit to 1% of
its original value in a selected amount of time, we used and compared three numerical methods
implemented in C++: the bisection, Newton-Raphson, and the secant methods. We will discover
the root of the function to find the appropriate amount of resistance desired for the circuit. These
calculations are crucial, for if the resistor is too strong or too weak, it will greatly affect the
functionality of the electrical circuit. When comparing the three numerical methods to solve the
roots, we found that the Newton-Raphson Method was closest to the calculated value. This
method produced the calculated value of the root of the equation: 328.151 ohms.

Figure 1 The electrical circuit we aim to design

Physical Analysis
We begin with acknowledging the current through the resistor drops the voltage can be
exemplified by: VR = iR, where VR is in voltage drop, i is current (in amperes), and R is
resistance (in ohms). The inductor also resists the change in current and has the expression of:
VL = L(dl/dt), where L is inductance (in henrys). VL represents the voltage drop across it.
Additionally, the voltage drops across the capacitor can be represented by: VC= q/C, where q is
the charge (in coulombs) and C is the capacitance (in farad). Following Kirchhoff’s second law, a
closed circuit has the sum of all the voltage drops are zero and can be written by:
(1) L(di/dt) + Ri + q/C = 0
We can manipulate this equation to get a second-order linear ordinary differential equation:

(2)
The solution to equation (1) that satisfies the initial conditions:

is (see appendix):

(3)
This solution can be rewritten as [1]:

(4).

Figure 2 The voltage function graphed in Wolfram Calculator

Numerical Analysis
A pseudocode for the bisection method is:
start
input a, b, delta, eps
if f(a)*f(b)<0
else input new a, b
endif
c = (a+b)/2
if f(a)*f(c)<0
b=c
else
a=c
endif
endif
display c
end
A flowchart for the Newton-Raphson method is:

Lastly, an algorithm for secant method is:


1. Input two initial guesses a, b, and a threshold for error e
2. Calculate c=b-(b-a)*f(b)/(f(b)-f(a)).
3. If |f(c)|<e or |( b - a)| < e display c, exit
Else set a = b, b = c
4. Repeat steps 2 and 3 until a certain number of iterations is achieved

Results
The circuit we are studying has the following initial conditions: L = 5H, C = 10-4F. We will use
an accuracy of 0.001. The Bisection Method produced a root of 328.125. In the Newton-Raphson
Method, it found the value of 328.151. The Secant Method was slightly off with computing the
value of 328.155. The Newton-Raphson Method gave the closest value to the value found using a
graphing calculator.
Conclusion
In this paper, we looked for the resistance of a given RLC circuit. The resistance was found as
the root of a function derived by applying Kirchhoff’s second law. The root finding methods used
were bisection, Newton-Raphson, and secant. Depending on the resources available, it is
important to study the type of root-finding methods in C++. In this case, we saw that the
Newton-Raphson Method held true over the Bisection and Secants Methods.
References
[1] Dr. Corina S. Drapaca, ESC 261M: Computational Methods for Engineers, Lecture 1 & 5.
Canvas, web. January, 2018.
Appendix
Code for Newton-Raphson Method:
#include<iostream>
#include<cmath>
using namespace std;

double f(double x);


double f(double x)
{
double a=exp(-x*0.005)*cos(sqrt(2000-pow(x/10,2))*0.05)-0.01;
return a;
}
double fprime(double x);
double fprime(double x)
{
double b= -0.005*exp(-x*0.005)*cos(sqrt(2000-pow(x/10,2))*0.05)-exp(-
x*0.005)*sin(sqrt(2000-pow(x/10,2))*0.05)*(-0.0005*x)/sqrt(2000-pow(x/10,2));

return b;

}
int main()
{
double x,x1,e,fx,fx1;
cout.precision(3);
cout.setf(ios::fixed);
cout<<"Enter the initial guess\n";
cin>>x1;
cout<<"Enter desired accuracy\n";
cin>>e;

fx=f(x);
fx1=fprime(x);
// cout <<"x{i}"<<" "<<"x{i+1}"<<" "<<"|x{i+1}-x{i}|"<<endl;

do
{
x=x1;
fx=f(x);
fx1=fprime(x);
x1=x-(fx/fx1);
cout<<x<<" "<<x1<<" "<<abs(x1-x)<<endl;
}while (fabs(x1-x)>=e);
cout<<"The root of the equation is "<<x1<<endl;
return 0;
}

Potrebbero piacerti anche