-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction
More file actions
48 lines (40 loc) · 1.15 KB
/
Copy pathfunction
File metadata and controls
48 lines (40 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from IPython.display import Math, display
import sympy as s
def funkcja(equation,a,nazwa,acc,unit='',pref=''):
try:
a_st=[]
for e,i in enumerate(a):
a_st.append(str(i))
a_s=s.symbols(nazwa)
expr=s.sympify(equation)
lista_1=[]
for e,i in enumerate(a_s):
lista_1.append([i,a_st[e]])
#print(lista_1)
wynik=expr.subs(lista_1)
lista_2=[]
for e,i in enumerate(a_s):
lista_2.append([i,a[e]])
wynik_k=expr.subs(lista_2)
c=wynik_k.evalf(acc)
f=s.Eq(expr,wynik)
slowo=''
slowo='$'
slowo+=pref
slowo+=s.latex(expr)
slowo+='='
slowo+=s.latex(wynik)
#slowo+=s.latex(f)
slowo+='='
slowo+=s.latex(c)
slowo+=unit
slowo+=2*chr(92)
slowo+='$'
display(Math(slowo))
return c
except Exception as e:
print("sprobuj jeszcze raz ",e)
#s=sympy.Eq(a, a.doit())
#print(sympy.latex(sympy.Eq(sympy.Integral(x,x), x**2/2)))
#print (sympy.latex(sympy.Integral(x**2+sympy.sin(x)*sympy.exp(x**2),x)))
#z=sympy.Integral(x,(x,1,2))