3 Oct 19:47 2015

### Defining a set of symbols that commute with another set of symbols

Hello,

I'd like to know if there is some way to define two sets of symbols, say:

A00,A01,A10,A11 = symbols('A00, A01, A10, A11')
B00
,B01,B10,B11 = symbols('B00, B01, B10, B11')

such that each Aab commutes with Bcd for all a,b,c,d \in {0,1}.

I think the trick here is that a single symbol may commute with more than just one other symbol. Is there anyway to do this in Sympy?

Thanks!

--
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.
3 Oct 05:54 2015

### Identifying expressions created with evaluate=False

I think I know the answer already, but just to be sure, if I have several expression objects (mostly Add and Mul), some of which were created with evaluate=False, is there any way to tell which those are?

--
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.
2 Oct 12:15 2015

### Sympy to theano printing for complex expressions.

Hello everybody,

Could somebody give me a hint how to introduce new operator mapping for sympy to theano code generation?

What are limitations of this mapping? For example, «We could map only subclass of expression to subclass of something else.»

I have got the following simplified test snippet:

from sympy import MatrixSymbol, Matrix, pprint, HadamardProduct
from sympy.abc import x, y

M
= 3
A
= 4

Nu = MatrixSymbol('Nu', M, A)
p
= MatrixSymbol('p', M, 2)

G
= Matrix([[1, 0, 0, 1, 1, 0],

[0, 0, 0, 1, 0, 0],

[0, 0, 1, 0, 1, 0],

[0, 0, 0, 0, 0, 1]])

fs
= [x*1+10,
x
*2+10,
x
*3+10,
x
*4+10,
x
*5+10,
x
*6+10]

F
= Matrix(M, len(fs), lambda i, j: fs[j].subs({x: x-p[i, 0], y: y-p[i, 1]}))

P
= Matrix([[Matrix(1, M, lambda i, j: 0 if j == k else 1)*(HadamardProduct(Nu*G, F))

for k in xrange(0, M)]])

pprint
(P, num_columns=500)

inputs
= [x, y, p]
outputs
= [P]
dtypes
= {inp: 'float64' for inp in inputs}

from sympy.printing.theanocode import theano_function
f
= theano_function(inputs, outputs)

Unfortunately, an attempt of code generation failed, since there is no mapping exists for MatrixElement.

File "/Users/aloschil/workspace/sympy/sympy/printing/theanocode.py", line 102, in _print_Basic
op
= mapping[type(expr)]
KeyError: <class 'sympy.matrices.expressions.matexpr.MatrixElement'>

I have made an assumption that I should add the following mapping:
MatrixElement -> Subtensor{int64, int64}.

I am missing something. I have got no clear vision of underlying ideas, that is why it is a little bit tricky for me to go ahead.

I did not dive into details and tried the following:

sympy.matrices.expressions.matexpr.MatrixElement: tt.var.TensorVariable

Unfortunately, this straightforward approach failed.

I would like to read documentation that describes core ideas, which lies behind operation building either in SymPy and Theano.

best regards,
Alexander.

--
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.
28 Sep 22:31 2015

### Testing question

I just want to make sure I understand how testing is supposed to work, before I start going through the code looking for the source of (what I think is) weirdness.

If I run sympy.test('test_frame') and get:

sympy/physics/vector/tests/test_frame.py[4] .EE.                               [FAIL]

_____________________________________________________________________________________
_______________ sympy
/physics/vector/tests/test_frame.py:test_ang_vel _______________

File "/users/kate/devstuff/sympy/sympy/physics/vector/tests/test_frame.py", line 65, in test_ang_vel
...

then I should be able to do
>>> from sympy.physics.vector.tests.test_frame import test_ang_vel
>>> test_ang_vel()

and get the same error, right?  Or is that not what is supposed to happen?

--
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.
24 Sep 12:43 2015

### Solver for Complex Geometry problem

Hello,

For a project I'm currently working on, I need to draw some parametrized shape. To achieve that I compute the complex coordinate of each point. The problem is that some shape are quiet complex and it's sometime hard to find the point's coordinate as a function of our parameters. To save some time for the next shape, I want to use SymPy to compute these coordinates. The idea would be to adapt validated equation system to describe the new shapes. So I tried this (simple) example :

with the following code (with the simplification P1 above P0 ie same reel part)

#Point to find (P0 to P5 only, P6 to P10 are found by symmetry)
var("P:6", complex=True)

#Available data
H0
, H1, H2, W0, W1, W2, Rbo =symbols ('H0, H1, H2, W0, W1, W2, Rbo', real=True,positive=True)

#Equation to solve
Eq_list = list()
Eq_list.append(P0 - Rbo)
Eq_list.append(P1 - P0-1j*W0/2.0)
Eq_list.append(P2 - P1 - H0)
Eq_list.append(P3 - P2 - H1-1j*(W1-W0)/2.0)
Eq_list.append(P4 -P2 - H1)
Eq_list.append(P5 - P4 -H2-1j*(W2-W0)/2.0)

result = solve (Eq_list,[P0, P1, P2, P3, P4, P5])

The result is as expected :
P0 = Rbo
P1
= Rbo + 0.5*I*W0
P2
= H0 + Rbo + 0.5*I*W0
P3
= H0 + H1 + Rbo + 0.5*I*W1
P4
= H0 + H1 + Rbo + 0.5*I*W0
P5
= H0 + H1 + H2 + Rbo + 0.5*I*W2

Now I want to remove my simplification (P1 must be on the circle, so it's not exactly above P0). So I change my equations for P1 this way :

Eq_list.append(Abs(P1) - Rbo)
Eq_list.append(im(P1)-im(P0)-W0/2.0)

The first equation states that P1 is on the circle of center (0,0) and radius Rbo, and the second one that P1 is on a line parallel to the abscissa passing by a point P0+1j*(W0/2).  The expected result is :
P1  = P0 * exp(1j*arcsin(W0/(2*Rbo)))
#Or P1 = Rbo * exp(1j*arcsin(W0/(2*Rbo)))

And I get (I'm using Python 2.7 and SymPy 0.7.6) :
NotImplementedError: solving Abs(P1) when the argument is not real or imaginary.

So the first thing I want to know is : I am doing this right ? Maybe my problem is just due to the fact that there are two solutions for P1 and that I need to state Re(P1) >0 (if it is possible). Or maybe be there is a better way to solve this kind of problem with SymPy (adding other assumption or equation, working with variables for both real and imaginary part of each point, using another function or module I'm not knowing about...).
Anyway, having a way to specify distance and angle between some points directly with the functions "Abs" and "arg" would be really helpful to solve this kind of problem. So I'm wondering, how hard would it be to implement the use of Abs and arg in your solver ? If it's at my reach I'm ready to implement it myself (with some help and workaround of course).

Best Regards,
Pierre Bonneel

--
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.
23 Sep 16:25 2015

### Simplify Equation

Consider the following:
>>> x, y, z = symbols('x y z', positive = True)
>>> equation = Eq(x*y*(x**5-x-y)*(x-y)/2,0)

My goal would be reducing equation to something like
(x**5-x-y)*(x-y)==0

removing the nonzero factors, but simplify(equation) doesn't work (and I think it isn't supposed to work like that).
Ideally, I would also like to be able to further reduce equation by assuming, for instance, that x!=y; in this case, equation should reduce to
x**5-x-y==0

So, what I'm trying to do is reducing equation without actually solving it, and I can't find any function that does that.
Any help would be greatly appreciated.

--
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.
22 Sep 18:50 2015

### Assumptions in solve()

Hey,

So I am going through the advanced example in the tutorial: Solve for r given V=4/3 * pi * r**3.

The solution is correct but I am wondering if I can get rid of unneeded solutions by giving a "list" of assumption like [ V>0, r>0 ].

Justin

--
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.
21 Sep 20:01 2015

### How to substitute var by arrays?

Dear Sympy developers and users,

Could anyone help me with the following problem:
substitute a, b, c by arrays in expression f = a*b*c. For example, I get "ValueError: The truth value of an array with more than one element is ambiguous" if running:
import sympy
import numpy
sympy.var('a,b,c')
f = a*b*c
array1 = numpy.random.randint(1,3,3)
array2 = numpy.random.randint(1,3,3)
array3 = numpy.random.randint(1,3,3)
f.subs([[a, array1], [b, array2], [c, array3]])

Best Regards
Ronghai Wu

--
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 18:58 2015

### Real Functions

How do I define a real function of a real variable?

X = symbols('x y z',real=True)

f = Function('f',real=True)(*X)

"real=True" in Function doesn't do anything.

--
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 07:51 2015

### Differential Equations - GSOC

Hey everyone!
I am interested in developing Differential Equations (ordinary and partial) for SymPy. I saw that some work has already been done in this context. I went through the documentation and realized that all the things I knew about were already developed. In fact there were many things I did not know which had been developed. So I wanted to know what all things are left and the resources from where I could know about the remaining things. I have currently no idea about partial differential equations but I am willing to learn something new. And also could you tell me how time I would have to dedicate aside for learning Differential Equations?

Pranit Bauva,
IIT Kharagpur.

--
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 13:12 2015

### Solving a system of equations fails

Hello,

I try to calculate the tangent of a circle. This is a quite simple system of equations (one is quadratic),
but sympy fails (empty solution set). Any idea why?

from __future__ import division
from sympy import *
from sympy.solvers import solve

init_printing(use_latex = True)
r, phi_0, phi_1, phi_2, beta_0, beta_1, beta_2= symbols('r phi_0, phi_1, phi_2, \
beta_0, beta_1, beta_2')

if True:
if True:
phi_0 = 0
beta_0 = 0
phi_1 = 1.
beta_1 = 1.
r=1.
eq1 = Eq((phi_2 - phi_1) * (phi_2 - phi_1) + (beta_2 - beta_1) * (beta_2 - beta_1) - r*r)
eq2 = Eq((phi_2 - phi_0) * (phi_2 - phi_1) + (beta_2 - beta_0) * (beta_2 - beta_1))
result = solve([eq1, eq2], phi_2)
print result

The result is an empty list. Any idea, how to fix this?
Expected result: phi_2 = 1.

Any hints appreciated!

U. Fechner, TU Delft

--
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.