Skip to content

Question for speed-up sp.expand() on specific function (or: How to use hints?) #25450

Discussion options

You must be logged in to vote

In general expansion is faster if you use Poly rather than Expr e.g. fct.as_poly(). You can convert back to Expr with fct.as_poly().as_expr() but if you want to do lots of arithmetic and have everything always expanded it is better to just keep everything as Poly while you do the arithmetic:

In [1]: e = '(vHa_*(trans_0*trans_3*exp(2.0*I*pi*phase_1)*exp(2.0*I*pi*phase_2)*a[H] - 1.0*sqrt(1 - t
   ...: rans_0**2)*sqrt(1 - trans_3**2)*a[H]) + sqrt(1 - vHa_**2)*(trans_0*trans_3*exp(2.0*I*pi*phase
   ...: _1)*exp(2.0*I*pi*phase_2)*a[V] - 1.0*sqrt(1 - trans_0**2)*sqrt(1 - trans_3**2)*a[V])*exp(2.0*
   ...: I*pi*vPa_))*(vHc_*(1.0*I*trans_0*sqrt(1 - trans_3**2)*a[H] + 1.0*I*trans_3*sqrt(1 - trans_0**

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MarioKrenn6240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants