Example #1
0
import math
import matplotlib.pyplot as plt

def f1(x):
    return 5*x**3 - 2*x**2 + 2*x -3

def f1_der(x):
    return 15*(x**2) - 4*x + 2

def f2(x):
    return math.sin(x)

def f2_der(x):
    return math.cos(x)

lista1, lista2 = calculus.derivacija(f1, -2, 2, 0.01, 2)
lista3, lista4 = calculus.derivacija(f1, -2, 2, 0.1, 2)
list1, list2 = calculus.derivacija(f2, -2, 2, 0.01, 2)
list3, list4 = calculus.derivacija(f2, -2, 2, 0.1, 2)

lista5 = []
for x in lista2:
    y = f1_der(x)
    lista5.append(y)

list5 = []
for x in list2:
    y = f2_der(x)
    list5.append(y)

s = [2]
Example #2
0
import matplotlib.pyplot as plt
import modul
import math
import calculus


def f1(x):
    return x * x - 2 * x


def f2(x):
    return math.sin(x)


def f3(x):
    return x**2


def f4(x):
    return 2 * x**2 + 3


def f4(x):
    return 5 * x**3 - 2 * x**2 + 2 * x - 3


print(modul.value(f1, 1))
print(modul.value(f2, 1))
print(calculus.derivacija2(f3, 0.01, 2))
print(calculus.derivacija(f3, 0.01, 2))
Example #3
0
File: pr.py Project: anahrgovic/PAF
import calculus 
import math
import numpy as np

def f1(x):
    return 5*(x**3)-2*(x**2)+2*x-3

print(calculus.derivacija(f1,1,5,0.1))
Example #4
0
import calculus
import math
import matplotlib.pyplot as plt


def f1(x):
    return 5 * (x**3) - 2 * (x**2) + 2 * x - 3


def f2(x):
    return x * x - 2 * x


print(calculus.deriv(f1, 1, 0.01))
print(calculus.deriv(f1, 1, 0.01))
print(calculus.derivacija(f1, 1, 5, 0.1))

a, b = calculus.derivacija(f1, -2, 2, 0.01)
plt.plot(a, b)
plt.show()
Example #5
0

def f4(x):
    return 5 * x**3 - 2 * x**2 + 2 * x - 3


xk1 = -2
xk2 = 2
hk = 0.1
x_l1 = np.arange(xk1, xk2, hk)
d_l1 = []
for x in x_l1:
    d = 15 * x**2 - 4 * x + 2
    d_l1.append(d)

a, b = calculus.derivacija(f4, 0.1, -2, 2)
plt.plot(x_l1, d_l1)
plt.scatter(a, b, s=5, color='r')
plt.show()


def ftrig(x):
    return math.sin(2 * x) - math.cos(x)


xt1 = -10
xt2 = 10
ht = 0.01
d_l2 = []
x_l2 = np.arange(xt1, xt2, ht)