31 Mar 00:12 2015

### Sine product integral

Dear all,

First of all, many thanks for Sympy, which is a great tools !

I try to integrate a product of two sinus functions such as :

f(x) = sin(pi*n/L*x) * sin(pi*m/L*x)

where n and m are two positive integer (and L>0). I've found the correct expected values (L/2 if m=n, 0 otherwise). But if I make a small change of variable, moving x to x+L/2, then Sympy fails to provide me an answer. Is there a way to "help" Sympy finding the correct solution ?

An example is below :

----

z = symbols('z')
m, n = symbols('m n', positive=True, integer=True)
L = symbols('L', positive=True, real=True)

def e1(z, n, L):
k_n = n*pi/L
return sin(k_n*(z))

def e2(z, n, L):
k_n = n*pi/L
return sin(k_n*(z+L/2))

Imn1 = integrate(fu(e1(z, n, L)*e1(z, m, L)), (z, 0, L))
Imn2 = integrate(fu(e2(z, n, L)*e2(z, m, L)), (z, -L/2, L/2))

---

In [16]: Imn1
Out[16]: Piecewise((L/2, m == n), (0, True))

In [17]: Imn2
Out[17]: Integral(sin(pi*m*(L/2 + z)/L)*sin(pi*n*(L/2 + z)/L), (z, -L/2, L/2))

Best regards,

Julien

--
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.
30 Mar 11:26 2015

### Recommendations for creating symbols

Hi all,

I'm wondering about the section on creating symbols in
https://github.com/sympy/sympy/wiki/Idioms-and-Antipatterns#strings-as-input
.

It is mildly discouraging importing from sympy.abc because an accidental
"from sympy.abc import *" would clobber I and Q (and possibly others),
and recommends
>>> import symbols
>>> x, y, z = symbols('x y z')

Now in https://github.com/sympy/sympy/pull/9219 , I applied this advice to
>>> from sympy.abc import t, w, x, y, z, n, k, m, p, i
and got
>>> t, w, x, y, z, n, k, m, p, i = symbols('t w x y z n k m p i')
I think that's actually really dangerous, because it's easy to swap two
letters without noticing so you essentially get the equivalent of
>>> p = Symbol('i')
>>> i = Symbol('p')
with the devious consequence that everything would still work but any
outputs would be utterly confusing because it would print 'p' wherever
the user expects 'i' and vice versa.

So... should I change the wiki to recommend sympy.abc over symbols()?

Regards,
Jo

--

--
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/551916B5.8090808%40durchholz.org.


30 Mar 07:13 2015

### How to give a Function a latex representation?

Hi--

I can give a symbol a latex representation with:

x1=symbols(r'x_{1}')

How do I create a function with a latex representation?

Ic=symbols(r'I_{C}',cls=Function)
Ic=Function(r'I_{C}')

Don't seem to work... They pretty print as strings.

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.
29 Mar 15:32 2015

### Limit of a symbol to a string

Hi,

>>> from sympy import symbols, limit
>>> x = symbols('x')
>>> a = "apple"
>>> limit(x, x, a)
apple

I do not know the meaning of the a symbol tending to a string.
Even if it is correct then what is its use or significance.

--
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 Mar 20:20 2015

### Making docs doesn't seem to use files in the repo, but installed files instead

I'd like to make some minor modifications to some docstrings and submit a pull request.  So I've checked out a copy of the repo, and I go into doc, then run make html.  Everything seems to work fine, no error messages, and I can open the html files under _build.  Looks good, sympy live works.

But now, when I make some changes and re-run make html, nothing happens -- the changes don't propagate to the new doc html files.  I can even make clean and make html again, but the changes I've made to the docstrings don't show up.  Turns out if I now run python setup.py install and make html again, the changes do show up.  So evidently, sphinx is finding the code from my installation directory rather than the code directory.  This is annoying and now how I want it to work.  I've also tried

PYTHONPATH=  make html

(The Makefile then prefixes .. to PYTHONPATH, so I would have guessed that it would just use the actual code files.)  But even this doesn't work.  I wonder if it's related to the fact that I use anaconda.

Is there any way I can force make html to use the actual code sitting right there next to it?

--
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 Mar 15:27 2015

### How do I construct this rational expression?

I need to update a unit test where integrate now returns something that
contains 1/(2*(s+1)).
However, when I write that subexpression, SymPy gives me 1/(2*s + 2),
which compares unequal.

What would be the best way forward?
Alternatives that I can think of:
- have integrate() do whatever SymPy does when constructing 1/(2*s + 2)
- have the unit test do it and leave integrate() as it is
- rewrite the unit test to directly construct the Expr object (how?)

--

--
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/5516BA6D.2090903%40durchholz.org.


28 Mar 14:02 2015

### Re: meijerint.py: Sorting in _mul_as_two_parts, _rewrite2

Am 28.03.2015 um 00:51 schrieb Aaron Meurer:
> On Fri, Mar 27, 2015 at 5:26 PM, Joachim Durchholz <jo@...> wrote:
>> The other approach would be to accept that some unit tests depend on sort
>> order in a superficial way, and to change the unit tests. (2)

changes: those to the sorting order, and those to all the tests that
actually depend on that sorting order (a dozen or two of them).

It's not going to be a monster PR, fortunately.

--

--
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/5516A665.5040803%40durchholz.org.


28 Mar 08:18 2015

### Re: meijerint.py: Sorting in _mul_as_two_parts, _rewrite2

Am 28.03.2015 um 00:51 schrieb Aaron Meurer:
> On Fri, Mar 27, 2015 at 5:26 PM, Joachim Durchholz <jo@...> wrote:
>> The other approach would be to accept that some unit tests depend on sort
>> order in a superficial way, and to change the unit tests. (2)
>
> Is the result deterministic?  And is it still mathematically correct?

Deterministic: yes.

Mathematically correct: Sort of, one Piecewise condition goes from
Ne(1/s, 1) to Ne(s, 1).
For SymPy, it is equivalent; for the human reader, it might be
considered mathematically "almost equivalent" due to the singularity at s=0.
With a mathematically incorrect result I'd assume a bug in the
integration algorithm anyway.

>> Is there a third, better approach?

I indeed came up with third approach tonight: keep the existing sort
order and remove the comment that it is outdated.
Not better, but correct enough to have a place on the list of options.

--

--
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/551655B5.9050300%40durchholz.org.


27 Mar 20:50 2015

### Restore Poly from dict

Suppose I have following polynomial:
poly= Poly(6*x**4*y**5 + 3*x*y**2,y,x)

It's dictionary is
poly.as_dict() # {(5, 4): 6, (2, 1): 3}

How can I restore poly from dict?
How do I know that (5, 4) - > (y, x) ?
poly.free_symbols is set, so it is unordered.

Is there any way to fetch that from Poly?

One way I think is following:

variables = [x,y]
poly
= Poly(6*x**4*y**5 + 3*x*y**2,variables)

#(5, 4) - > variables

And next question: how are coeffcients are ordered? Can I change order? order keyword throws exception...

--
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.
27 Mar 19:30 2015

### expanding powers of cos()

Hi,

I'm relatively new to SymPy, and enjoying it so far.  I'm trying to analyze the harmonics that result when a sinusoid goes through a non-linear system.  I have an expression that includes powers of a cos() and I want to expand it using the sum/difference angle identities.  So I want

In [5]: some_function(cos(x)**2)
Out[5]: 1/2 + cos(2*x)

But I'm getting
In [5]: expand_trig(cos(x)**2)
Out[5]: cos(x)**2

I've tried expand_trig(), trigsimp(), expand() (with several different sets of hints), simplify(), and http://www.sympygamma.com/ and they all just return the same expression that I've given them.  Any ideas would be much appreciated.

Thanks,
Jeremy

--
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.
27 Mar 17:31 2015

### rsolve example symbol

I am attempting to rsolve a recursion and am having a problem.  Doctoring up the first example the live window follows.  Please note that I changed (n**2 + 3*n - 2) to (n**2 + 3*n - k) and then no output results. Is this because it won't handle parameters or am I supposed to do things differently?
Ray

Python console for SymPy 0.7.6 (Python 2.7.5) These commands were executed: >>> from __future__ import division >>> from sympy import * >>> x, y, z, t = symbols('x y z t') >>> k, m, n = symbols('k m n', integer=True) >>> f, g, h = symbols('f g h', cls=Function)
>>> from sympy import Function, rsolve
>>> f = (n - 1)*y(n + 2) - (n**2 + 3*n - 2)*y(n + 1) + 2*n*(n + 1)*y(n)
>>> rsolve(f, y(n))
2nC0+C1n!
>>> from sympy import Function, rsolve
>>> from sympy.abc import n
>>> from sympy.abc import n
>>> y = Function('y')
>>> y = Function('y')
>>> f = (n - 1)*y(n + 2) - (n**2 + 3*n - 2)*y(n + 1) + 2*n*(n + 1)*y(n)
>>> rsolve(f, y(n))
2nC0+C1n!
>>> f = (n - 1)*y(n + 2) - (n**2 + 3*n - k)*y(n + 1) + 2*n*(n + 1)*y(n)
>>> rsolve(f, y(n))

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