1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 20 14:40:48 2025
@author: christian
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Parameters
A = 1.0 # initial amplitude
b = 0.2 # damping coefficient
f = 1.0 # frequency (Hz)
time = np.linspace(0, 5, 1000) # time vector
# Dampened sine wave formula
displacement = A * np.exp(-b * time) * np.sin(2 * np.pi * f * time)
velocity = np.gradient(displacement, time)
acceleration = np.gradient(velocity,time)
# Plotting
plt.figure(figsize=(8, 5))
plt.plot(time, displacement, label='disp. (m)', color='blue')
plt.plot(time, velocity, label='vel. (m/s)', color='red')
plt.plot(time, acceleration, label='acc. (m/s^2)', color='black')
plt.title('Pendulum')
plt.xlabel('Time (s)')
plt.ylabel('f(t)')
plt.grid(True)
plt.legend()
plt.tight_layout()
plt.show()
|