Skip to content

Instantly share code, notes, and snippets.

@smichr
Created August 5, 2011 20:46
Show Gist options
  • Save smichr/1128484 to your computer and use it in GitHub Desktop.
Save smichr/1128484 to your computer and use it in GitHub Desktop.
DEMO
regular
```python
>>> (1/x+1/y+1/z+1/w).as_numer_denom()
(w*x*y + w*x*z + w*y*z + x*y*z, w*x*y*z)
```
binary-horner
```python
>>> (1/x+1/y+1/z+1/w+1/u).binary()
(u*x*y*z + w*(u*z*(x + y) + x*y*(u + z)), u*w*x*y*z)
```
TIMING
as_numer_denom4
```python
>>> T('Add(*(1/Dummy() for i in xrange(1000))).as_numer_denom4()','from sympy.abc import x\nfrom sympy import Add, Dummy, expand_mul',number=1)
92.80784145648727
```
binary-horner
```python
>>> T('Add(*(1/Dummy() for i in xrange(1000))).binary()','from sympy.abc importx\nfrom sympy import Add, Dummy',number=1)
1.7147244170380138
```
binary-expanded
```python
>>> T('a=Add(*(1/Dummy() for i in xrange(1000))).binary();expand_mul(a[0])','from sympy.abc import x\nfrom sympy import Add, Dummy, expand_mul',number=1)
172.02092018891028
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment