This repository contains three different Python scripts to calculate the equivalent resistance of an infinite ladder network, using three distinct approaches:
- Iterative Loop Approach (loop.py)
- Recursive Approach (recursive.py)
- Quadratic Equation Approach (quadratic.py)
Each script takes two resistor values R1 and R2 as inputs and calculates the equivalent resistance of the infinite ladder network using its respective method.
-
R1
: Resistance value of resistor 1.R2
: Resistance value of resistor 2.
The equivalent resistance R_eq of the infinite ladder network.
This script implements an iterative loop to approximate the equivalent resistance.
The script repeatedly updates an initial guess for the equivalent resistance using the formula:
The iteration continues until the difference between successive values of R_eq
is smaller than a specified tolerance (1e-6
by default), or a maximum number of iterations is reached.
This script implements a recursive solution for the calculation of the equivalent resistance.
The script uses recursion to model the infinite network, assuming that after enough recursions, the resistance will converge to a final value. A base case is defined when 500 iterations are reached (considered sufficient for convergence).
This script solves the equivalent resistance using a quadratic equation.
By rearranging the equation for the infinite ladder network, the problem can be reduced to solving a quadratic equation:
The quadratic formula is used to find the two possible solutions, and the positive one is selected as the equivalent resistance.
- @nforoutann I'm a Computer Engineering (Computer Science) student at Shahid Beheshti University, passionate about technology, a lifelong learner, and professional nerd.