Wiggles is a powerful and flexible Python library for generating, manipulating, and visualizing signals developed by Ranit Bhowmick & Sayanti Chatterjee. Whether you're working with continuous or discrete signals, Wiggles provides a wide range of functionalities to make signal processing straightforward and intuitive. It supports operations in both the time domain and frequency domain, including Fast Fourier Transform (FFT) and inverse FFT, and allows for easy conversion between different representations.
Wiggles is designed to be easy to use and integrate into your existing Python workflows, making it a valuable tool for engineers, researchers, and anyone interested in signal processing.
• Download Wiggles
• Wiggles Documentation (With Images & Outputs)
• Example Codes
- Generation of continuous and discrete signals
- Conversion between time domain and frequency domain
- Support for common signal types like sine waves, square waves, and more
- Visualization of signals
- Export and import of signals to various formats
- Playback of signals as audio
Ensure Python 3.10 is installed in the system and added to the system variables. Install the library through pip with the command:
pip install wiggles
Here are examples of generating and visualizing basic signals using Wiggles.
A sine wave, sinusoidal wave, or just sinusoid is a mathematical curve defined in terms of the sine trigonometric function, of which it is the graph. It is a type of continuous wave and also a smooth periodic function. It occurs often in mathematics, as well as in physics, engineering, signal processing, and many other fields.
where:
-
$A$ represents the amplitude, which is the peak deviation of the function from zero. -
$f$ represents the ordinary frequency, which is the number of oscillations (cycles) that occur each second of time. -
$\omega = 2 \pi f$ represents the angular frequency, which is the rate of change of the function argument in units of radians per second. -
$\phi$ represents the phase, which specifies (in radians) where in its cycle the oscillation is at$t = 0$ . When$\phi$ is non-zero, the entire waveform appears to be shifted in time by the amount$\frac{\phi}{\omega}$ seconds. A negative value represents a delay, and a positive value represents an advance.
- Ensure Python 3.10 is installed in the system and added to the system variables.
- Install the library through pip with the command:
pip install wiggles
- Use VS Code to code and test out the results.
- The code is written to find the best solution to the given problem and then is evaluated and displayed using the inbuilt
show()
orcompare()
function in Wiggles.
Generate sine waves in Python and plot them using Wiggles.
import math
from wiggles import signals as sp
# Adjust using these variables
A = 2
f = 5
w = 2 * f * math.pi
Q = 0
# The sin function
def sin(t):
return A * math.sin((w * t) + Q)
# Building the continuous signal
y = sp.continuous(sin)
# Adjusting properties and displaying the continuous signal
y.name = "sin(t)"
y.show()
# Building the discrete signal
y2 = sp.continuous(sin, step=0.01)
y2.is_descrete = True
# Adjusting properties and displaying the discrete signal
y2.name = "sin[t]"
y2.show()
A cosine wave is a mathematical curve defined in terms of the cosine trigonometric function, of which it is the graph. It is a type of continuous wave and also a smooth periodic function. It occurs often in mathematics, as well as in physics, engineering, signal processing, and many other fields.
where:
-
$A$ : Amplitude, the peak deviation of the function from zero. -
$f$ : Ordinary frequency, the number of oscillations (cycles) that occur each second of time. -
$\omega = 2 \pi f$ : Angular frequency, the rate of change of the function argument in units of radians per second. -
$\phi$ : Phase, specifies (in radians) where in its cycle the oscillation is at$t = 0$ . When$\phi$ is non-zero, the entire waveform appears to be shifted in time by the amount$\phi / \omega$ seconds. A negative value represents a delay, and a positive value represents an advance.
Generate cosine waves in Python and plot them using Wiggles.
import math
from wiggles import signals as sp
# Adjust using these variables
A = 2
f = 5
w = 2 * f * math.pi
Q = 0
# The cos function
def cos(t):
return A * math.cos((w * t) + Q)
# Building the continuous signal
y = sp.continuous(cos)
# Adjusting properties and displaying the continuous signal
y.name = "cos(t)"
y.show()
# Building the discrete signal
y2 = sp.continuous(cos, step=0.01)
y2.is_descrete = True
# Adjusting properties and displaying the discrete signal
y2.name = "cos[t]"
y2.show()
The exponential function is a mathematical function denoted by
where:
-
$A$ : Amplitude, the peak deviation of the function from zero. -
$\omega$ : Angular frequency, the rate of change of the function argument in units of radians per second.
Generate exponentially growing and exponentially decaying waves in Python and plot them using Wiggles.
import math
from wiggles import signals as sp
# Adjust using these variables
A = 2
a = -4
# The exp function
def exp(t):
return A * math.exp(-1 * a * t)
# Building the signal
y = sp.continuous(exp)
# Adjusting properties and displaying the signal
y.name = "Exponentially Growing"
y.show()
from wiggles import signals as sp
# Adjust using these variables
A = 2
a = 4
# The exp function
def exp(t):
return A * math.exp(-1 * a * t)
# Building the signal
y = sp.continuous(exp)
# Adjusting properties and displaying the signal
y.name = "Exponentially Decaying"
y.show()
Generation of Exponentially Growing and Decaying Sinusoidal Curves in Python using the Custom Library Wiggles
The exponential function is a mathematical function denoted by
- Exponential:
$y(t) = A e^{-t}$ - Sinusoidal:
- Sine:
$y(t) = A \sin(\omega t + \phi) = A \sin(2 \pi f t + \phi)$ - Cosine:
$y(t) = A \cos(\omega t + \phi) = A \cos(2 \pi f t + \phi)$
- Sine:
Where:
-
$A$ : Amplitude, the peak deviation of the function from zero. -
$f$ : Ordinary frequency, the number of oscillations (cycles) that occur each second of time. -
$\omega = 2 \pi f$ : Angular frequency, the rate of change of the function argument in units of radians per second. -
$\phi$ : Phase, specifies (in radians) where in its cycle the oscillation is at$t = 0$ .
Generate exponentially growing and exponentially decaying sine and cosine waves in Python and plot them using Wiggles.
import math
from wiggles import signals as sp
# Adjust using these variables
A = 1
a = -5
f = 7
w = 2 * f * math.pi
Q = 0
# The exp function
def exp(t):
return A * math.exp(-1 * a * t)
# The sin function
def sin(t):
return A * math.sin((w * t) + Q)
# Building and operating on the signal
expwave = sp.continuous(exp)
sinwave = sp.continuous(sin)
expsin = expwave * sinwave
# Adjusting properties and displaying the signal
expwave.name = "Exponentially Growing Wave"
sinwave.name = "Sin Wave"
expsin.name = "Exponentially Growing Sin"
expwave.compare(sinwave, expsin, spacing=0.407)
import math
from wiggles import signals as sp
# Adjust using these variables
A = 1
a = 5
f = 7
w = 2 * f * math.pi
Q = 0
# The exp function
def exp(t):
return A * math.exp(-1 * a * t)
# The sin function
def sin(t):
return A * math.sin((w * t) + Q)
# Building and operating on the signal
expwave = sp.continuous(exp)
sinwave = sp.continuous(sin)
expsin = expwave * sinwave
# Adjusting properties and displaying the signal
expwave.name = "Exponentially Decaying Wave"
sinwave.name = "Sin Wave"
expsin.name = "Exponentially Decaying Sin"
expwave.compare(sinwave, expsin, spacing=0.407)
import math
from wiggles import signals as sp
# Adjust using these variables
A = 1
a = -5
f = 7
w = 2 * f * math.pi
Q = 0
# The exp function
def exp(t):
return A * math.exp(-1 * a * t)
# The cos function
def cos(t):
return A * math.cos((w * t) + Q)
# Building and operating on the signal
expwave = sp.continuous(exp)
coswave = sp.continuous(cos)
expsin = expwave * coswave
# Adjusting properties and displaying the signal
expwave.name = "Exponentially Growing Wave"
coswave.name = "Cos Wave"
expsin.name = "Exponentially Growing Cos"
expwave.compare(coswave, expsin, spacing=0.407)
import math
from wiggles import signals as sp
# Adjust using these variables
A = 1
a = 5
f = 7
w = 2 * f * math.pi
Q = 0
# The exp function
def exp(t):
return A * math.exp(-1 * a * t)
# The cos function
def cos(t):
return A * math.cos((w * t) + Q)
# Building and operating on the signal
expwave = sp.continuous(exp)
coswave = sp.continuous(cos)
expsin = expwave * coswave
# Adjusting properties and displaying the signal
expwave.name = "Decaying Growing Wave"
coswave.name = "Cos Wave"
expsin.name = "Decaying Growing Cos"
expwave.compare(coswave, expsin, spacing=0.407)
Theory
An ideal impulse signal is a signal that is zero everywhere but at the origin (
Expression
PROBLEM
Generate unit impulse signal in Python and plot it using the same.
PROGRAM CODE
from wiggles import signals as sp
# Building amplitude data for unit impulse
length = 20
y = ([0] * length) + [1] + ([0] * length)
# Making signal using the amplitude data 'y' using wiggles and displaying
unitimpulse = sp.discrete(y, -length)
unitimpulse.name = "Unit Impulse"
unitimpulse.show()
Theory
The step signal or step function is a standard signal that exists only for positive time and is zero for negative time. In other words, a signal
Expression
PROBLEM
Generate unit step signals in Python and plot them using the same.
PROGRAM CODE
from wiggles import signals as sp
# Building amplitude data for unit Step
length = 20
y = ([0] * length) + ([1] * length)
# Making signal using the amplitude data 'y' using wiggles
unitimpulse = sp.discrete(y, -length)
# Naming and displaying the signal
unitimpulse.name = "Unit Step"
unitimpulse.show()
Theory
A ramp function or ramp signal is a standard signal that starts at
Expression
PROBLEM
Generate a ramp signal in Python and plot it using the same.
PROGRAM CODE
from wiggles import signals as sp
# Building amplitude data for Ramp
length = 20
y = [i for i in range(length)]
# Making signal using the amplitude data 'y' using wiggles
unitimpulse = sp.discrete(y)
# Naming and displaying the signal
unitimpulse.name = "Ramp"
unitimpulse.show()
Theory
An ideal impulse signal is a signal that is zero everywhere but at the origin (
Expression
PROBLEM
Generate unit impulse signals using user-defined functions in Python and plot them.
PROGRAM CODE
from wiggles import signals as sp
# Making signal using the abstracted user-defined function
unitimpulse = sp.unit_impulse(-20, 20)
unitimpulse.name = "Unit Impulse"
unitimpulse.show()
Theory
The step signal or step function is a standard signal that exists only for positive time and is zero for negative time. In other words, a signal
Expression
PROBLEM
Generate unit step signals in Python using user-defined functions and plot and display the signal.
PROGRAM CODE
from wiggles import signals as sp
# Making signal using the inbuilt function we developed in wiggles and displaying it
unitstep = sp.unit_step(-20, 20)
unitstep.name = "Unit Step"
unitstep.show()
Theory
Shifting means moving a signal either in the time domain or in the amplitude domain. This can be categorized into:
-
Time Shifting: Movement in the time domain. If
$k$ is positive, the signal shifts left; if$k$ is negative, the signal shifts right.
Expression
PROBLEM
Time shift a test signal by a specific value and display it in a subplot to study the change and compare.
PROGRAM CODE
from wiggles import signals as sp
# Test signal y; Making discrete signal using wiggles
y = sp.discrete([2, -2, 3, -3, 4], -3)
y.name = "y"
# Shifting the signal 'y' by 1
y1 = y.TimeShift(1)
# Comparing two signals
y.compare(y1)
Theory
Time scaling involves multiplying the time axis of a signal by a constant. This process can result in:
-
Time Compression: If
$\alpha > 1$ , the signal is compressed in time by a factor of$\alpha$ . -
Time Expansion: If
$\alpha < 1$ , the signal is expanded in time by a factor of$\alpha$ .
Expression
PROBLEM
Time scale a test signal by a specific value and display it in a subplot to study the change and compare.
PROGRAM CODE
from wiggles import signals as sp
# Test signal y; Making discrete signal using wiggles
y = sp.discrete([2, -2, 3, -3, 4], -3)
y.name = "y"
# Scaling the signal 'y' by 2
y1 = y.TimeScale(2)
# Comparing two signals
y.compare(y1)
Theory
Time reversal involves multiplying the time variable by -1, which produces a mirror image of the signal about the Y-axis.
Expression
PROBLEM
Time reverse a test signal by a specific value and display it in a subplot to study the change and compare.
PROGRAM CODE
from wiggles import signals as sp
# Test signal y; Making discrete signal using wiggles
y = sp.discrete([2, -2, 3, -3, 4], -3)
y.name = "y"
# Reversing the signal 'y'
y1 = y.reverse()
# Comparing two signals
y.compare(y1)
Theory
Convolution is a mathematical tool for combining two signals to produce a third signal. It is crucial in signal processing as it relates the input signal and the impulse response of the system to generate the output signal. For continuous signals, convolution involves integrating the product of the signals over time.
Expression
PROBLEM
Perform convolution between two signals starting from the same index and display the results.
PROGRAM CODE
from wiggles import signals as sp
# Creating two test signals (Starting from the same index)
x1 = sp.discrete([-1, 2, -3, 1], -1)
x1.name = "x1"
x2 = sp.discrete([3, 0, 1, -4], -1)
x2.name = "x2"
# Performing convolution and displaying the result
result = x1.convolve(x2)
x1.compare(x2, result)
Theory
Convolution combines two signals to produce a third signal, relating the input signal and the impulse response to generate the output signal. For continuous signals, it involves integrating the product of the signals over time.
Expression
PROBLEM
Perform convolution between two signals starting from different indices and display the results.
PROGRAM CODE
from wiggles import signals as sp
# Creating two test signals (Starting from different index)
x1 = sp.discrete([-1, 2, -3, 1], -1)
x1.name = "x1"
x2 = sp.discrete([3, 0, 1, -4], -3)
x2.name = "x2"
# Performing convolution and displaying the result
result = x1.convolve(x2)
x1.compare(x2, result)
Theory
The commutative property of convolution states that the order in which two signals are convolved does not affect the result. This means:
Expression
PROBLEM
Implement and verify the commutative property of convolution.
PROGRAM CODE
from wiggles import signals as sp
# Creating two test signals
x1 = sp.discrete([-1, 2, -3, 1], -1)
x1.name = "x1"
x2 = sp.discrete([3, 0, 1, -4], -3)
x2.name = "x2"
'''
Commutative Property of Convolution:
The commutative property of convolution states that the order in which
we convolve two signals does not change the result,
i.e.,
x1(t) * x2(t) = x2(t) * x1(t)
'''
# Calculating LHS:
lhs = x1.convolve(x2)
# Calculating RHS:
rhs = x2.convolve(x1)
# Displaying both results
lhs.compare(rhs)
Theory
The distributive property of convolution states that convolution distributes over addition. For three signals (x_1(t)), (x_2(t)), and (x_3(t)), this means:
Expression
PROBLEM
Implement and verify the distributive property of convolution.
PROGRAM CODE
from wiggles import signals as sp
# Creating three test signals
x1 = sp.discrete([-1, 2, -3, 1], -1)
x1.name = "x1"
x2 = sp.discrete([3, 0, 1, -4], -3)
x2.name = "x2"
x3 = sp.discrete([5, 6, 7, 8], -2)
x3.name = "x3"
'''
Distributive Property of Convolution:
The distributive property of convolution states that
if there are three signals x1(t), x2(t), and x3(t),
then the convolution of x1(t) is distributive over the addition,
i.e.,
x1(t) * [x2(t) + x3(t)] = [x1(t) * x2(t)] + [x1(t) * x3(t)]
'''
# Calculating LHS:
lhs = x1.convolve(x2 + x3)
# Calculating RHS:
rhs = (x1.convolve(x2)) + (x1.convolve(x3))
# Displaying both results
lhs.compare(rhs)
Theory
The associative property of convolution states that the grouping of signals in convolution does not affect the result. This means:
Expression
PROBLEM
Implement and verify the associative property of convolution.
PROGRAM CODE
from wiggles import signals as sp
# Creating three test signals
x1 = sp.discrete([-1, 2, -3, 1], -1)
x1.name = "x1"
x2 = sp.discrete([3, 0, 1, -4], -3)
x2.name = "x2"
x3 = sp.discrete([5, 6, 7, 8], -2)
x3.name = "x3"
'''
Associative Property of Convolution:
The associative property of convolution states that the way in which
the signals are grouped in a convolution does not change the result,
i.e.,
x1(t) * [x2(t) * x3(t)] = [x1(t) * x2(t)] * x3(t)
'''
# Calculating LHS:
lhs = x1.convolve(x2.convolve(x3))
# Calculating RHS:
rhs = (x1.convolve(x2)).convolve(x3)
# Displaying both results
lhs.compare(rhs)
Theory
The sum of two discrete time signals (x_1[n]) and (x_2[n]) can be obtained by adding their values at every instant of time.
PROBLEM
Implement and verify the result after adding two discrete signals.
PROGRAM CODE
from wiggles import signals as sp
# Creating two test signals
x = sp.discrete([-1, 2, -3, 1], -1)
x.name = "x"
y = sp.discrete([3, 0, 1, -4], -3)
y.name = "y"
# Performing operation and displaying the result
result = x + y
x.compare(y, result)
Theory
The difference of two discrete time signals (x_1[n]) and (x_2[n]) can be obtained by subtracting their values at every instant of time.
PROBLEM
Implement and verify the result after subtracting two discrete signals.
PROGRAM CODE
from wiggles import signals as sp
# Creating two test signals
x = sp.discrete([-1, 2, -3, 1], -1)
x.name = "x"
y = sp.discrete([3, 0, 1, -4], -3)
y.name = "y"
# Performing operation and displaying the result
result = x - y
x.compare(y, result)
Theory
The multiplication of two discrete time signals (x_1[n]) and (x_2[n]) can be obtained by multiplying their values at every instant of time.
PROBLEM
Implement and verify the result after multiplying two discrete signals.
PROGRAM CODE
from wiggles import signals as sp
# Creating two test signals
x = sp.discrete([-1, 2, -3, 1], -1)
x.name = "x"
y = sp.discrete([3, 0, 1, -4], -3)
y.name = "y"
# Performing operation and displaying the result
result = x * y
x.compare(y, result)
Theory
The division of two discrete time signals (x_1[n]) and (x_2[n]) can be obtained by dividing their values at every instant of time.
PROBLEM
Implement and verify the result after dividing two discrete signals.
PROGRAM CODE
from wiggles import signals as sp
# Creating two test signals
x = sp.discrete([-1, 2, -3, 1], 0)
x.name = "x"
y = sp.discrete([3, 1, 1, -4], 0)
y.name = "y"
# Performing operation and displaying the result
result = x / y
x.compare(y, result)
Theory
A signal is said to be an even signal if it is symmetrical about the vertical axis or time origin. Every signal need not be purely even or purely odd; instead, it can be expressed as the sum of even and odd components. The even component of any signal can be calculated by:
PROBLEM
Implement and verify the calculation of the even component of a signal.
PROGRAM CODE
from wiggles import signals as sp
# Creating a test signal
x = sp.discrete([-1, 8, -3, 4], 0)
x.name = "x"
# Finding the even component and displaying the result
component = x.even_component()
component.name = "Even Component"
x.compare(component)
Theory
A signal is said to be an odd signal if it is anti-symmetrical about the vertical axis. Every signal need not be purely even or purely odd; instead, it can be expressed as the sum of even and odd components. The odd component of any signal can be calculated by:
PROBLEM
Implement and verify the calculation of the odd component of a signal.
PROGRAM CODE
from wiggles import signals as sp
# Creating a test signal
x = sp.discrete([-1, 8, -3, 4], 0)
x.name = "x"
# Finding the odd component and displaying the result
component = x.odd_component()
component.name = "Odd Component"
x.compare(component)
Theory
Every signal need not be purely even or purely odd; instead, it can be expressed as the sum of even and odd components:
Where:
- (x_e(t)) is the even component of the signal
- (x_o(t)) is the odd component of the signal
PROBLEM
Verify by adding the even and odd components of the signal to retrieve the original signal.
PROGRAM CODE
from wiggles import signals as sp
# Creating a test signal
x = sp.discrete([-1, 8, -3, 4], 0)
x.name = "x"
# Finding the even component
even = x.even_component()
even.name = "Even Component"
# Finding the odd component
odd = x.odd_component()
odd.name = "Odd Component"
# Adding the two components
'''
Since:
Every signal need not be either purely even or purely odd,
but it can be expressed as the sum of even and odd components.
x(t) = x_e(t) + x_o(t)
Where:
x_e(t) is the even component of the signal,
x_o(t) is the odd component of the signal.
'''
verify = even + odd
verify.trim()
# Displaying the results
x.compare(even, odd, verify)
PROBLEM
Generation of different types of signals using operations involving unit impulse signals. Given:
Where ( -5 < n < 5 ).
Getting the environment ready
Python 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command pip install wiggles
. VS Code is used for coding and testing. The code is evaluated and displayed using the show()
or compare()
function in Wiggles.
PROGRAM CODE
from wiggles import signals as sp
# Generating unit impulse signal
us = sp.unit_impulse()
us.name = "unit impulse"
# Performing operation
x = (2 * us.TimeShift(2)) - us.TimeShift(-4)
x.name = "result"
# Trimming and displaying result
x.trim()
us.compare(x)
PROBLEM
Generation of different types of signals using operations involving unit step signals. Given:
Where ( 0 \leq n \leq 20 ).
Getting the environment ready
Python 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command pip install wiggles
. VS Code is used for coding and testing. The code is evaluated and displayed using the show()
or compare()
function in Wiggles.
PROGRAM CODE
from wiggles import signals as sp
import numpy as np
import math
# Generating unit step signal
u = sp.unit_step(21)
u.name = "unit step"
# Generating array as desired
n = sp.array(np.arange(0, 21, 1))
n.name = "array"
# Performing operation
x = (n * (u - u.TimeShift(-10))) + (10 * (math.e ** (-0.3 * (n - 10)))) * (u.TimeShift(-10) - u.TimeShift(-20))
x.trim()
x.name = "result"
# Trimming and displaying result
u.compare(n, x)
PROBLEM
Generation of different types of signals using operations involving other signals. Given:
Starting index = -2
Determine and plot the following sequences:
- $$ x_1[n] = 2 \cdot x[n - 5] - 3 \cdot x[n + 4] $$
- $$ x_2[n] = x[3 - n] + x[n] \cdot x[n - 2] $$
Getting the environment ready
Python 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command pip install wiggles
. VS Code is used for coding and testing. The code is evaluated and displayed using the show()
or compare()
function in Wiggles.
PROGRAM CODE
from wiggles import signals as sp
# Generating wiggles wave using the given amplitude data
x = sp.discrete([1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1], -2)
x.name = "x"
# Operation 1 (a)
x1 = (2 * x.TimeShift(-5)) - (3 * x.TimeShift(4))
x1.name = "operation 1"
# Operation 2 (b)
x2 = x.operate(-1, 3) + (x * x.TimeShift(-2))
x2.name = "operation 2"
# Displaying the result
x.compare(x1, x2)
Theory
A function is said to be a piecewise continuous function if it has a finite number of breaks and it does not blow up to infinity anywhere. The Laplace transform of a function ( f(t) ), represented as ( L{f(t)} ) or ( F(s) ), is defined by the integral transform:
where ( s = \sigma + j\omega ) is a complex variable.
Getting the environment ready
Python 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command pip install wiggles
. VS Code is used for coding and testing. The code is evaluated and displayed using the show()
or compare()
function in Wiggles.
PROBLEM
Find the Laplace transform of the following signals:
- ( x(t) = 2 \cdot \delta(t) + e^{-3t} )
- ( x(t) = u(t-1) - 2e^{-t} )
PROGRAM CODE 1
from wiggles import symbols as sy
# Given Expression
def x(t):
return sy.unit_impulse(t) + sy.exp(-3 * t)
# Making time domain object
expression = sy.time_domain(x)
print("The Expression in time Domain: ", expression)
# Laplace transformation
y = expression.laplace_transform()
print("The Expression in frequency Domain is: ", y)
PROGRAM CODE 2
from wiggles import symbols as sy
# Given Expression
def x(t):
return sy.unit_step(t - 1) - sy.exp(-2 * (-t))
# Making time domain object
expression = sy.time_domain(x)
print("The Expression in time Domain: ", expression)
# Laplace transformation
y = expression.laplace_transform()
print("The Expression in frequency Domain is: ", y)
Theory
The inverse Laplace transform of a function ( F(s) ) is given by:
where the integration is along the vertical line ( \text{Re}(s) = \gamma ) in the complex plane, with ( \gamma ) being greater than the real part of all singularities of ( F(s) ).
Getting the environment ready
Python 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command pip install wiggles
. VS Code is used for coding and testing. The code is evaluated and displayed using the show()
or compare()
function in Wiggles.
PROBLEM A
Find the inverse Laplace transform of the following signals:
- ( X(s) = \frac{10s^2 + 4}{s(s + 1)(s + 2)^2} )
- ( X(s) = \frac{s^3 + 2s + 6}{s(s + 3)(s + 1)^2} )
PROGRAM CODE 1
from wiggles import symbols as sy
# Given Expression
def x(s):
return (10 * s**2 + 4) / (s * (s + 1) * (s + 2)**2)
# Making frequency domain object
expression = sy.frequency_domain(x)
expression.name = "X(s)"
print("The Expression in frequency Domain: ", expression)
# Inverse Laplace transformation
y = expression.inverse_laplace_transform()
y.name = "x(t)"
print("The Expression in Time Domain is: ", y)
PROGRAM CODE 2
from wiggles import symbols as sy
# Given Expression
def x(s):
return (s**3 + 2 * s + 6) / (s * (s + 3) * (s + 1)**2)
# Making frequency domain object
expression = sy.frequency_domain(x)
expression.name = "X(s)"
print("The Expression in frequency Domain: ", expression)
# Inverse Laplace transformation
y = expression.inverse_laplace_transform()
y.name = "x(t)"
print("The Expression in Time Domain is: ", y)
PROBLEM B
Use commands to fragment the expression and find the inverse Laplace transform:
Given:
PROGRAM CODE 1
from wiggles import symbols as sy
# Given Expression
def x(s):
return (4 * s**5 + 20 * s**4 + 11 * s**3 + 10 * s**2 - 12) / (s**4 + 5 * s**3 + 8 * s**2 + 4 * s)
# Making frequency domain object
expression = sy.frequency_domain(x)
expression.name = "X(s)"
print("The Expression in frequency Domain: \n", expression)
# Expanding and fragmenting the expression
expression.apart()
print("The Expanded and processed expression: \n", expression)
# Inverse Laplace transformation
y = expression.inverse_laplace_transform()
y.name = "x(t)"
print("The Expression in Time Domain is: \n", y)
Theory
The zeros are the roots of the numerator, and the poles are the roots of the denominator of a transfer function.
Getting the environment ready
Python 3.10 is installed in the system and added to the system variables. The library is installed through pip with the command pip install wiggles
. VS Code is used for coding and testing. The code is evaluated and displayed using the show()
or compare()
function in Wiggles.
PROBLEM
Find the roots of the numerator and the denominator to compute the poles and the zeros of the expression:
Given:
PROGRAM CODE
from wiggles import symbols as sy
# Given Expression
def x(s):
return (s**2 + 3 * s + 1) / (s**3 + 4 * s**2 + 3 * s)
# Creating frequency domain object
expression = sy.frequency_domain(x)
expression.name = "X(s)"
print("The Expression in frequency Domain: \n", expression)
# Finding out poles and zeros and displaying
polezero = expression.roots()
print("Poles of the expression:", polezero['poles'])
print("Zeros of the expression:", polezero['zeros'])