Home > other >  Using sympy python library special slow calculation equation
Using sympy python library special slow calculation equation

Time:10-09

If to replace U1 with digital is particularly fast, use sympy calculation is particularly,
U1=sympy. Symbol (' U1)
Qd1=dict ()

Def a (k) :
If k==0:
The return of 126.6

The else:
If 'a1 + STR (k - 1) in qd1:
Aval=qd1 [' a1 + STR (k - 1)]
The else:
Aval=a (k - 1)
Qd1 [' a1 + STR (k - 1)]=aval

If "q1" + STR (k - 1) not in vd1:
Qval=q (k - 1)
Vd1 [' q1 + STR (k - 1)]=qval
The else:
Qval=vd1 [' q1 + STR (k - 1)]
Aaaa=qd1 [' a1 + STR (k - 1)]
BBBB=qd1 [' a1 + STR (k - 1)]

P1=aval + (U1 - aaaa * BBBB)/120
Return p1

If __name__=="__main__ ':
# function (' function ')
S=0
Print (qd1)
For k in range (0, 30) :
K=k
Key='a1 + STR (k)
Val=a (k)
If the key not in qd1:
Qd1 [key]=val
Print (a (k))
  • Related