23 Sep 00:17 2014

### Interest in a banded matrix solver?

Most of the matrices I deal with have a banded structure coming from a finite-difference representation. I noticed that for such matrices, the DOK implementation is far from optimal so I implemented a matrix diagonal storage form (http://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solve_banded.html) where
ab[u + i - j, j] == a[i,j].I also implemented a banded solver that is significantly faster for such matrices. Here's a brief sample

np = 100
sol
= randMatrix(np, 1)
upper
, lower = 1, 3

def fd_mat(i, j, upper=upper, lower=lower, np=np):

for shift in range(-upper, lower+1):

if i==j+shift:

return randint(shift, high=2*np//(abs(shift)+1))
s
= SparseMatrix(np, np, fd_mat)

In [408]:
%timeit s.LUsolve(sol)
1 loops, best of 3: 15.7 s per loop

In [411]:
%%timeitoff, m = to_dia(s)l_and_u = (abs(min(off)), max(off))lu = diag_lu(l_and_u, m)banded_solve(l_and_u, lu, sol)
1 loops, best of 3: 385 ms per loop
In [412]:
(s.LUsolve(sol) - banded_solve(l_and_u, lu, sol)).is_zero
Out[412]:
True
Where to_dia, diag_lu and banded_solve are my custom routines. Is there any interest in turning this into a PR or am I the only one who has banded matrices?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
19 Sep 05:32 2014

### Help with aliasing assumptions

I have a new SymPy type that serves to represent a unit of computation (contains an expression/expressions that is/are being computed). I'd like to be able to alias queries on the assumptions of the element to assumptions of the underlying expression it represents. Example:

>>> a, b, c = symbols('a, b, c', integer=True)
>>> expr = a + b + c

# Create the tree element
>>> r = Routine((a, b, c), (expr))

# r now represents a computational routine.
# We can use this as a function in other expressions.
>>> new_expr = 1 + 2 + r(a, b, c)
>>> new_expr
1 + 2 + r(a, b, c)

# The following should work
>>> new_expr.is_integer
True
>>> r(1, 2, 3).is_integer
True

For `Routine` objects with multiple returns, the results are indexed to select the output element:

>>> exprs = (a + b + c, a*b*c + 4.1)
>>> r = Routine((a, b, c), exprs)

# Use it in a new expression
>>> (1 + r(1, 2, 3)[0]).is_integer
True
>>> (1 + r(1, 2, 3)[1]).is_integer
False

Any idea how to go about doing this? I have little to no understanding of the assumption system, so before I start digging through the code I thought I'd ask if anyone had thoughts on how to tackle this. The `Routine` type, the `AppliedRoutine` type, and the results/arguments are all done. I just need to figure out (if possible) how I can make this play well with the assumption system.

-Jim

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
18 Sep 20:29 2014

### Fwd: Python Weekly - Issue 157

Jim's slides on SymPy code gen got into the Python weekly.

Jason
moorepants.info
+01 530-601-9791

---------- Forwarded message ----------
From: Python Weekly
Date: Thu, Sep 18, 2014 at 11:06 AM
Subject: Python Weekly - Issue 157
To: moorepants-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

 Email not displaying correctly? View it in your browser.

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AjK72cVppMb1yHK9BckFg7fWkinTFnue4tpH3v7mu99Mw%40mail.gmail.com.
18 Sep 19:02 2014

### note regarding travis testing

If you have a PR then TWO tests are initiated for each push: one in your personal travis account and one in the sympy account. If you kill one it does not (apparently) kill the other. So if you want to keep things from bogging down, kill runs in both places.

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
18 Sep 05:20 2014

### value of (-1)**(2*n)

If n is an unbounded integer (is there such a thing?) then which rule applies to the expression (-1)**(2*n): (-1)**oo = nan or (-1)**even = 1?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
16 Sep 21:59 2014

### [RFC] finite and bounded

Does anyone have a good reference for the definition of finite 0 < abs(x) < oo and bounded (abs(x) < oo) that they could add to https://github.com/sympy/sympy/pull/8043 ?

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
15 Sep 11:31 2014

### Use subs to replace subexpression with symbol

I'm trying to replace a nested function with a symbol by applying subs.

However, this doesn't seem to work for every case:
For Equation (2) my code below prints what I expect:

D_star =

C_vss
D_th
──────────
C_vth

But for Equation (3) subs doesn't seem to work and f_v is printed rather longish as:

f_v =

3/2

_________    ⎞⎞

φ          ⎟⎟

C_tD_th⋅⎜    ─── + 1  - 1⎟⎟               3/2

⎝╲╱   φ_t         ⎠⎟          ___

-k₁⋅⎜────────────────────────────⎟   ⋅⎝1 + ╲╱ 2

C_vth⋅φ
f_max
⋅⎝1 -

Any idea why subs is not working for Equation (3)?
Thanks!
Arne

Code example:
import sympy as sp
s = sp.Symbol
print 'sympy version ' + sp.__version__ + '\n'

def s_print(func_str, repl_str=None):
'''Print function and replace subexpression'''
print func_str + ' = \n'
if repl_str != None:
sp.pprint(eval(func_str).subs(eval(repl_str), s(repl_str)))
else:
sp.pprint(eval(func_str))
print '\n'

# (1) C_vss
phi, phi_t, C_t = sp.symbols('phi phi_t C_t')
C_vss = (sp.sqrt(2) + 1)*C_t*(sp.sqrt(1 + phi/phi_t) - 1)
s_print('C_vss')

# (2) D_star
C_vth, D_th = sp.symbols('C_vth D_th')
D_star = C_vss/C_vth * D_th
s_print('D_star', 'C_vss')

# (3) f_v
f_max, k_1, Phi = sp.symbols('f_max k_1, Phi')
f_v = f_max * (1 - sp.exp(-k_1 * (D_star/phi)**(sp.Rational(3,2))))
s_print('f_v', 'D_star')

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
12 Sep 09:21 2014

### can sympy do this

since out of memory,

i hope sympy can do this, but i can not find this function

http://www.mapleprimes.com/questions/202338-Error-in-Combinatpermute-Maple

how to do the same as in above link,  my post

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
12 Sep 05:07 2014

### Simple operations on equations

I have been playing with SymPy and IPython Notebook and thought it
would be useful to be able to explicitly perform some of the
operations that are in the toolset taught in a high-school algebra
class.

This would be things like
• Adding the same thing to both sides of an equation.
• Creating a new equation by adding two other equations together.
• Substituting one equation into another.

I realize that all of these are easy to synthesize from the existing
operations in SymPy, but didn't see them in any sort of a pre-packaged
form.

Are they there but I have just missed them?

If not, would they be a worthwhile addition to SymPy?

In case there is any ambiguity, I am speaking explicitly of the
Equality/Eq relations.  I know that SymPy and many other packages tend
to just use expressions with an implicit ==0 condition, but, in an
elementary context, explicit equations seem more familiar/easier to
understand.

The main use case would be when using a notebook to show the explicit
steps of a derivation.  (And especially at the level of high-school
algebra or science.)  In one of my physics notebooks I noticed myself
writing a lot of things like

eq3_4 = eq3_3.subs(eq2_1.rhs, eq2_1.lhs)

and thinking that having a well-documented set of idioms could add clarity.

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
10 Sep 16:52 2014

### Expanding abstract symbols in terms of their values

```Hi,

I'm working on an extension for sympy.diffgeom. Since expressions
often get very complicated in differential geometry, it sometimes
makes sense to e.g. simply keep a tensor as the indexed symbol it
is, sometimes one inserts its actual components' values (and
tries to simplify further). Put differently, my mathematical
objects (mostly tensors) carry names but also have values and I'd
like to let the user decide when he wants use what and enable him
to replace names by their values later on (without the need for
him to use replace()/subs() because this requires way too much
manual effort).

Basically, this is the analogy of the famous pitfall:

>>> x, y = symbols('x, y')
>>> y = x + 2
>>> x = 2
>>> y
x + 2

whereas I would actually like to provide a way to do exactly
this: Replace the symbol 'x' by its value later on.

(Obviously, this would allow lazy calculation of tensor
components. Hence, the user could build expressions involving
tensors without needing to calculate all of their components
first – after all, he might only need some of them.)

So: Are there any best practices in this regard or is there even
a general function in SymPy to expand/evaluate such abstract
symbols in terms of their (still abstract/non-numerical) values?

I imagine something like this:

>>> R[0, 1, 0, 1]
R_{0101}
>>> R[0, 1, 0, 1].expand() (or .eval()/.doit()/.compute() or something)
<some complicated expression in terms of coordinate functions>

--

--
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+unsubscribe@...
To post to this group, send email to sympy@...
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/878ulr1q9u.fsf%40simonhirscher.de.

```
10 Sep 03:54 2014

### More sugar for Buchberger's algorithm?

Hi All,

I've been using the polynomials module in SymPy, and it's great stuff. I noticed that your implementation of Buchberger's algorithm uses the normal selection strategy for choosing which pair to look at next. I was wondering if there would be any interest in a pull request that implements the "sugar" strategy outlined in Giovini & Mora (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.7.1065)? I think it's supposed to be a little better when computing with lex orderings.

Also, does the SymPy community have a benchmark for efficiency of the groebner() implementations? If not, and if there's interest in one, I'd be happy to help with that too.

Thanks!
Will

--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to sympy-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.