Python

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/4

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

5 Terms

1
New cards
term image

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()

2
New cards
term image

def min_diff(f, a, h):

return (f(a + h) - f(a)) / h

3
New cards
term image

theta0 = 1

h = 0.01

for _ in range(10):

theta0 = theta0 - r(theta0) / min_diff(r, theta0, h)

print("Minsta nollställe:", theta0)

4
New cards
term image

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)

5
New cards