1/4
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import fsolve
def r(theta):
return (2 + np.sin(3*theta)) / np.sqrt(1 + np.exp(np.cos(theta))) - 1
theta = np.linspace(1, 6, 100)
plt.plot(theta, r(theta))
plt.grid()
for guess in [1, 2, 3, 4, 5]:
root = fsolve(r, guess)
plt.plot(root, r(root), 'ro')
plt.show()
def min_diff(f, a, h):
return (f(a + h) - f(a)) / h
theta0 = 1
h = 0.01
for _ in range(10):
theta0 = theta0 - r(theta0) / min_diff(r, theta0, h)
print("Minsta nollställe:", theta0)
n = 100
theta = np.linspace(0, 6, n)
x = theta
y = r(theta)
length = 0
for i in range(n-1):
dx = x[i+1] - x[i]
dy = y[i+1] - y[i]
length += np.sqrt(dx**2 + dy**2)
print("Längd:", length)