PARALLEL
This function builds the equivalent transfer function for two linear time-invariant systems connected in parallel. In a parallel interconnection, both systems receive the same input and their outputs are added together to form the overall response.
For transfer functions G_1(s) and G_2(s), the combined system is
G(s) = G_1(s) + G_2(s)
The wrapper accepts each system as a 2-row coefficient array of the form [[numerator], [denominator]], converts them to python-control transfer functions, and returns the combined result as the library’s formatted transfer-function string.
Excel Usage
=PARALLEL(sys_a, sys_b)
sys_a(list[list], required): Numerator and denominator of the first system G1.sys_b(list[list], required): Numerator and denominator of the second system G2.
Returns (str): String representation of the resulting parallel-connected system.
Example 1: Two systems in parallel
Inputs:
| sys_a | sys_b |
|---|---|
| 1 | 1 |
| 1 | 1 |
Excel formula:
=PARALLEL({1;1,1}, {1;1,2})
Expected output:
"<TransferFunction>: sys[2]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\n 2 s + 3\n -------------\n s^2 + 3 s + 2"
Example 2: First-order paths with different gains in parallel
Inputs:
| sys_a | sys_b |
|---|---|
| 2 | 5 |
| 1 | 1 |
Excel formula:
=PARALLEL({2;1,3}, {5;1,1})
Expected output:
"<TransferFunction>: sys[5]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\n 7 s + 17\n -------------\n s^2 + 4 s + 3"
Example 3: Integrator combined with a first-order lag
Inputs:
| sys_a | sys_b |
|---|---|
| 1 | 3 |
| 1 | 1 |
Excel formula:
=PARALLEL({1;1,0}, {3;1,2})
Expected output:
"<TransferFunction>: sys[8]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\n 4 s + 2\n ---------\n s^2 + 2 s"
Example 4: Second-order plant in parallel with a static gain
Inputs:
| sys_a | sys_b |
|---|---|
| 1 | 2 |
| 1 | 1 |
Excel formula:
=PARALLEL({1;1,4,5}, {2;1})
Expected output:
"<TransferFunction>: sys[11]\nInputs (1): ['u[0]']\nOutputs (1): ['y[0]']\n\n 2 s^2 + 8 s + 11\n ----------------\n s^2 + 4 s + 5"
Python Code
Show Code
import control as ct
def parallel(sys_a, sys_b):
"""
Parallel interconnection of two LTI systems.
See: https://python-control.readthedocs.io/en/latest/generated/control.parallel.html
This example function is provided as-is without any representation of accuracy.
Args:
sys_a (list[list]): Numerator and denominator of the first system G1.
sys_b (list[list]): Numerator and denominator of the second system G2.
Returns:
str: String representation of the resulting parallel-connected system.
"""
try:
def to2d(value):
return [[value]] if not isinstance(value, list) else value
def parse_coefficients(row, label):
if not isinstance(row, list):
return None, f"Error: {label} must be a list of coefficients"
coefficients = []
for item in row:
if item is None or str(item).strip() == "":
continue
try:
coefficients.append(float(item))
except (TypeError, ValueError):
return None, f"Error: {label} contains a non-numeric coefficient"
if not coefficients:
return None, f"Error: {label} must contain at least one numeric coefficient"
return coefficients, None
def to_tf(data, label):
matrix = to2d(data)
if not isinstance(matrix, list) or len(matrix) < 2:
return None, f"Error: {label} must be provided as [[numerator], [denominator]]"
numerator, error = parse_coefficients(matrix[0], f"{label} numerator")
if error:
return None, error
denominator, error = parse_coefficients(matrix[1], f"{label} denominator")
if error:
return None, error
return ct.tf(numerator, denominator), None
g1, error = to_tf(sys_a, "sys_a")
if error:
return error
g2, error = to_tf(sys_b, "sys_b")
if error:
return error
res = ct.parallel(g1, g2)
return str(res)
except Exception as e:
return f"Error: {str(e)}"