As you have a string representation of your object, a non-sympy way is by
using string regex:
In [1]: expr = eval(Add(Mul(Integer(-1), Integer(2), Symbol('g'),
Symbol('psi^ss_1'), conjugate(Symbol('psi^ss_1'))), Mul(Integer(-1),
Integer(2), Symbol('g'), Symbol('psi^ss_2'),
A better alternative:
In [1]: from sympy import *
In [2]: expr = eval(Add(Mul(Integer(-1), Integer(2), Symbol('g'),
Symbol('psi^ss_1'), conjugate(Symbol('psi^ss_1'))), Mul(Integer(-1),
Integer(2), Symbol('g'), Symbol('psi^ss_2'),
conjugate(Symbol('psi^ss_2'))), Symbol('omega_2'),
On Friday, June 6, 2014 2:36:34 AM UTC+2, jeanbi...@gmail.com wrote:
var('A,B,C,D,u,v,qi,qf')
qi = 1/(u-I*v)
qf = (A+B/qi)/(C+D/qi)
First of all, you don't need to declare *qi* and *qf* in var( ... ),
because they get overwritten in the next expressions.
By the way, maybe you mean that
Tnx!
I think there is an error in the line (unbalanced paranthesis):
return node.xreplace ({e: S.One, conjugate(e): S.One})*abs(e)**2)
Also, do you know how I can force the factorization of the 2*g to get
2*g(|psi1|**2 + |psi2|**2)?
On Friday, June 6, 2014 10:45:37 AM UTC+2, F. B. wrote:
A
On Friday, June 6, 2014 12:22:14 PM UTC+2, Andrei Berceanu wrote:
Tnx!
I think there is an error in the line (unbalanced paranthesis):
return node.xreplace ({e: S.One, conjugate(e): S.One})*abs(e)**2)
Yes, sorry, just remove the last parenthesis.
Also, do you know how I can force the
That fixed the error, however, the problem is now if I apply this function
to expressions like
-2*g*conjugate(psi^ss_1)*conjugate(psi^ss_2)
I get
-2*g*conjugate(psi^ss_1)*Abs(psi^ss_2)**2
so it looks like the pattern matching is working overtime, since it should
leave the expression
The unflatten_mul function factorized the 2, but not the g, i.e. it returns
2(g*|psi1|**2 + g*|psi2|**2)
instead of
2g*(|psi1|**2 + |psi2|**2)
On Friday, June 6, 2014 1:07:26 PM UTC+2, F. B. wrote:
On Friday, June 6, 2014 12:22:14 PM UTC+2, Andrei Berceanu wrote:
Tnx!
I think there is
Hello.
All the receipts in this dicussion look very interesting.Maybe all of this
ones could be put in the official documentation.
Christophe BAL
2014-06-06 13:34 GMT+02:00 Andrei Berceanu andreiberce...@gmail.com:
The unflatten_mul function factorized the 2, but not the g, i.e. it returns
I agree, this could be helpful to many people. But first let's make sure we
iron out all the bugs.
And then I suppose one could re-write the expressions in a more
user-friendly form?
What do you propose, Chris?
On Friday, June 6, 2014 2:16:15 PM UTC+2, Christophe Bal wrote:
Hello.
All the
Try to use this one:
from sympy.unify import unify
def to_abs(node):
if not isinstance(node, Mul):
return node
zm1, zm2 = symbols('zm1, zm2')
m = unify(node, zm1 * zm2 * conjugate(zm2), {}, variables=[zm1, zm2])
try:
m = next(m)
except:
return node
On Friday, June 6, 2014 1:34:04 PM UTC+2, Andrei Berceanu wrote:
The unflatten_mul function factorized the 2, but not the g, i.e. it returns
2(g*|psi1|**2 + g*|psi2|**2)
instead of
2g*(|psi1|**2 + |psi2|**2)
Try to do so:
def get_unflattener(m):
m_args = list(m.args)
I have no special ideas to propose except to start with the examples in
this discussion. Maybe different working methods can be shown.
2014-06-06 14:23 GMT+02:00 Andrei Berceanu andreiberce...@gmail.com:
I agree, this could be helpful to many people. But first let's make sure
we iron out all
I think that SymPy needs a better term rewriting system. And also a better
pattern matcher.
--
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
A easy to use treeview will be a great tool. No ?
2014-06-06 19:52 GMT+02:00 F. B. franz.bona...@gmail.com:
I think that SymPy needs a better term rewriting system. And also a better
pattern matcher.
--
You received this message because you are subscribed to the Google Groups
sympy group.
Well yes, but that doesn´t change the fact that in Mathematica I can just do
expr /.{x_*Conj[x_] - Abs[x]^2}
and it just works!
On Friday, June 6, 2014 8:59:56 PM UTC+2, Christophe Bal wrote:
A easy to use treeview will be a great tool. No ?
2014-06-06 19:52 GMT+02:00 F. B.
By the way, I just found another case where the modulus value squared
substitution fails:
a, b, c, d = symbols('a b c d')
expr = a*b*conjugate(a)*conjugate(b) + c*d*conjugate(c)*conjugate(d)
bottom_up(chain(rebuild, to_abs))(expr)
-- a*conjugate(a)*Abs(b)**2 + c*conjugate(c)*Abs(d)**2
instead
I define a function gamma with the following code:
from sympy import *
x = Symbol('x')
class gamma(Function): pass
Its latex representation is
print latex(gamma(x))
\Gamma\left(x\right)
whereas I would like it to be
\gamma\left(x\right)
i.e. lowercase instead of capital.
How can I achieve
Hallo everybody,
I'm sorry for this question, but I'm not realy familar with Python.
Normally I'm working with PHP and JavaScript, but for my recent project I
have to integrate some symbolic math to a webpage.
In an Internet search, I came across Sympy. And sympy looks quite good.
My problem
On Friday, 6 June 2014 23:13:39 UTC+2, Andrei Berceanu wrote:
I define a function gamma with the following code:
from sympy import *
x = Symbol('x')
class gamma(Function): pass
Its latex representation is
print latex(gamma(x))
\Gamma\left(x\right)
whereas I would like it to be
On Friday, 6 June 2014 23:18:19 UTC+2, Peter wrote:
Hallo everybody,
I'm sorry for this question, but I'm not realy familar with Python.
Normally I'm working with PHP and JavaScript, but for my recent project I
have to integrate some symbolic math to a webpage.
In an Internet search, I
I am doing all check out of documentation locally. The pdf file (also
rst and html) is on my computer. Note that I just upgraded my
computer. Before (Amd Phenom II, 6 cores) the Mathjax took 15 seconds
to render.
On 06/06/2014 07:21 PM, Aaron Meurer wrote:
Did that include time
Hi Björn,
In the meantime, I tried to install SympyGamma and the Google app engine, as
it is described in the manual. Unfortunately I don't know now how I can
check if everything works fine, because some steps were discribed for a
localhost and not on a remote server.
Until today, I've never
You might want to look at http://krum.rz.uni-mannheim.de/jas/ (Java
Algebra System (JAS) Project)
On 06/06/2014 08:16 PM, Peter wrote:
Hi Björn,
In the meantime,
ItriedtoinstallSympyGammaandtheGoogleappengine,asitisdescribedinthemanual.
These are all issues that Harsh should be addressing in his GSoC project.
Aaron Meurer
On Wed, Jun 4, 2014 at 6:56 AM, F. B. franz.bona...@gmail.com wrote:
I had a look at SymPy, it looks like this:
In [1]: solve(cos(3*x), x)
Out[1]:
⎡π π⎤
⎢─, ─⎥
⎣6 2⎦
In [2]: solve(cos(n*x), x)
Peter!
I dont understand what is it exactly that you want to do but still I would
like to help.
On 7 Jun 2014 06:00, Alan Bromborsky abro...@verizon.net
javascript:_e(%7B%7D,'cvml','abro...@verizon.net'); wrote:
In the meantime, I tried to install SympyGamma and the Google app engine,
as it
I just answered this on gitter earlier today, but you can just take the
jacobian of the system to get its matrix form. For example:
In [1]: from sympy import *
In [2]: a, b, c, d = symbols('a, b, c, d')
In [3]: x1, x2, x3, x4 = symbols('x1:5')
In [4]: x = Matrix([x1, x2, x3, x4])
In [5]:
26 matches
Mail list logo