Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- @author: Ante
- """
- import numpy as np
- import matplotlib.pyplot as plt
- from scipy.optimize import fsolve
- from scipy.integrate import odeint
- def f1(x):
- return np.sin(x)
- def f2(x):
- return np.cos(x)
- def f(x):
- return f1(x) - f2(x)
- x = np.linspace(0, 20, 100)
- plt.plot(x, f1(x), 'g', label='f1')
- plt.plot(x, f2(x), 'r', label='f2')
- plt.legend()
- n = []
- for i in range(3):
- n.append(fsolve(f, 3*i)[-1])
- n = np.array(list(set(n)))
- plt.scatter(n, f1(n), marker='o', color='blue')
- plt.fill_between(x, f1(x), color='lightblue')
- p1 = np.trapz(f1(x), x, dx=0.2)
- p2 = np.trapz(f2(x), x, dx=0.2)
- print('Razlika: ', p2-p1)
- def dif_eq(z, t):
- return 3.2*z*np.sin(np.sqrt(z))
- t = np.linspace(0, 10, 100)
- z = odeint(dif_eq, [10, -1], t)
- plt.figure()
- plt.plot(t, z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement