simple question

瀏覽次數:41 次
跳到第一則未讀訊息

Marco Inacio

未讀,
2016年10月21日 下午3:02:192016/10/21
收件者:sympy
Hi, out of curiosity I wanted to know why does this:

from sympy.solvers import solve
from sympy import Symbol,exp
x=Symbol("x")
solve(x*10e-4+exp(x),x)

runs much faster than this:

from sympy.solvers import solve
from sympy import Symbol,exp
x=Symbol("x")
solve(x+exp(x/10e-4),x)

(?) Thanks!

Aaron Meurer

未讀,
2016年10月21日 下午3:06:552016/10/21
收件者:sy...@googlegroups.com
The difference is only a few hundred milliseconds for me on SymPy
master (it's a 4x difference, but time that small could end up
corresponding to something trivial). You'd need to profile the
functions to see the difference. LIkely one is taking a slightly
different code path than the other.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/e9c9c294-066b-4149-8ae9-82c7b48ed3ac%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Marco Inacio

未讀,
2016年10月21日 晚上7:09:112016/10/21
收件者:sympy
Thanks, could you also run

from sympy.solvers import solve
from sympy import Symbol,exp,Eq

IS=7.443e-14; BF=1343.59; BR=62.79; VT=26.03e-3

IB=Symbol("IB")
VBE=Symbol("VTB")
E=100
RT=5
solve([Eq(IB, IS*(exp(VBE)/BF - 1/BF - 1/BR)), Eq(IB, (E - VBE*VT)/RT)], [IB, VBE])

and 

from sympy.solvers import solve
from sympy import Symbol,exp,Eq

IS=7.443e-14; BF=1343.59; BR=62.79; VT=26.03e-3

IB=Symbol("IB")
VBE=Symbol("VTB")
E=100
RT=5
solve([Eq(IB, IS*(exp(VBE/VT)/BF - 1/BF - 1/BR)), Eq(IB, (E - VBE)/RT)], [IB, VBE])

? The last one no only takes a lot of time, but is also eating lots of RAM, maybe it's something related to my computer or something that was already patched in master branch (I'm using the latest version on pip3).

As for profiling, I don't know much about it, I tried cProfile.run and the first finished with 966802 function calls (907997 primitive calls) in 2.835 seconds

The second one, I stop before finish (increasly eating RAM) with 318160249 function calls (318145924 primitive calls) in 112.793 seconds, what got my attention was
        8   82.562   10.320  112.439   14.055 densebasic.py:920(dup_from_dict)
     10/6    0.000    0.000  112.439   18.740 densebasic.py:978(dmp_from_dict)

Richard Fateman

未讀,
2016年10月30日 中午12:51:122016/10/30
收件者:sympy
Hi Marco.

I suggest you learn to use the "subject" line for something relevant.



回覆所有人
回覆作者
轉寄
0 則新訊息