import numpy as np
import pandas as pd
# Given parameters
V = 100 # Voltage in volts
R = 1 # Resistance in ohms
L = 0.1 # Inductance in henries
# Time constant tau = L / R
tau = L / R
# Times (in seconds) for which to calculate the current
times = np.array([0, tau, 2*tau, 5*tau])
# Initial steady-state current
I_steady = V / R
# Current at each time (exponential approach to steady state)
I_t
= I_steady
* (1 - np.
exp(-times
/ tau
))
# Create a DataFrame to display the values
data = {
'Time (s)': times,
'Current (A)': I_t
}
df = pd.DataFrame(data)
df
aW1wb3J0IG51bXB5IGFzIG5wCmltcG9ydCBwYW5kYXMgYXMgcGQKCiMgR2l2ZW4gcGFyYW1ldGVycwpWID0gMTAwICAjIFZvbHRhZ2UgaW4gdm9sdHMKUiA9IDEgICAgIyBSZXNpc3RhbmNlIGluIG9obXMKTCA9IDAuMSAgIyBJbmR1Y3RhbmNlIGluIGhlbnJpZXMKCiMgVGltZSBjb25zdGFudCB0YXUgPSBMIC8gUgp0YXUgPSBMIC8gUgoKIyBUaW1lcyAoaW4gc2Vjb25kcykgZm9yIHdoaWNoIHRvIGNhbGN1bGF0ZSB0aGUgY3VycmVudAp0aW1lcyA9IG5wLmFycmF5KFswLCB0YXUsIDIqdGF1LCA1KnRhdV0pCgojIEluaXRpYWwgc3RlYWR5LXN0YXRlIGN1cnJlbnQKSV9zdGVhZHkgPSBWIC8gUgoKIyBDdXJyZW50IGF0IGVhY2ggdGltZSAoZXhwb25lbnRpYWwgYXBwcm9hY2ggdG8gc3RlYWR5IHN0YXRlKQpJX3QgPSBJX3N0ZWFkeSAqICgxIC0gbnAuZXhwKC10aW1lcyAvIHRhdSkpCgojIENyZWF0ZSBhIERhdGFGcmFtZSB0byBkaXNwbGF5IHRoZSB2YWx1ZXMKZGF0YSA9IHsKICAgICdUaW1lIChzKSc6IHRpbWVzLAogICAgJ0N1cnJlbnQgKEEpJzogSV90Cn0KCmRmID0gcGQuRGF0YUZyYW1lKGRhdGEpCmRmCg==