1 Jul 13:30 2008

### evaluate multivariate expressions


Hey,
I'd like to use Sympy to compute gradients and Hessians of real valued
functions.

I got this far:
#---------------------------------------------------------------------
#!/usr/bin/env python

from numpy import *
from sympy import *

N = 3
x = [Symbol('x%d'%n) for n in range(N)]

# define function f: R^N -> R
f = 1
for n in range(N):
f *= x[n]
print 'function=',f

g = array([ diff(f,x[n]) for n in range(N)])

# compute Hessian
H = array([[diff(g[m],x[n]) for m in range(N)] for n in range(N)])

print 'Hessian=\n',H



1 Jul 15:03 2008

### Re: evaluate multivariate expressions


Hi Sebastian!

On Tue, Jul 1, 2008 at 1:30 PM, b45ch1 <sebastian.walter@...> wrote:
>
> Hey,
> I'd like to use Sympy to compute gradients and Hessians of real valued
> functions.
>
> I got this far:
> #---------------------------------------------------------------------
> #!/usr/bin/env python
>
> from numpy import *
> from sympy import *
>
> N = 3
> x = [Symbol('x%d'%n) for n in range(N)]
>
> # define function f: R^N -> R
> f = 1
> for n in range(N):
>        f *= x[n]
> print 'function=',f
>
> g = array([ diff(f,x[n]) for n in range(N)])
>
> # compute Hessian


1 Jul 16:13 2008

### ANN: SfePy 00.46.02


I am pleased announce the release of SfePy 00.46.02.

SfePy is a finite element analysis software in Python, based primarily
on Numpy and SciPy.

Mailing lists, issue tracking, mercurial repository: http://sfepy.org

Major improvements:
- alternative short syntax for specifying essential boundary conditions,
variables and regions
- manufactured solutions tests:
- SymPy support
- site configuration now via script/config.py + site_cfg.py
- new solvers
- new terms

If you happen to come to Leipzig for EuroSciPy 2008, see you there!

Best regards,
Robert Cimrman & SfePy developers


1 Jul 17:38 2008

### Re: Identifying repeated subexpressions in systems of equations


On Thu, Jun 19, 2008 at 10:10 AM, Ondrej Certik <ondrej@...> wrote:
> On Thu, Jun 19, 2008 at 7:42 AM, Robert Kern <robert.kern@...> wrote:
>>
>> On Wed, Jun 18, 2008 at 05:44, Ondrej Certik <ondrej@...> wrote:
>>>
>>> On Wed, Jun 18, 2008 at 11:50 AM, Robert Kern
<robert.kern@...> wrote:
>>
>>>> I can probably implement multiple expression support + unit tests +
>>>> subtraction preprocessing in a few days time.
>>>
>>> Excellent. In this case, let's go the 3) way.
>>
>> Where should the code go in the package?
>
> Let's put it to sympy/simplify/
>
> It is in fact a simplification.

Any progress on this? I think it's time to make anothe release, let's
say on Monday. If you are busy, I propose to put the code that we have
in (with my patch and a comment how to proceed with fixing it
generally) and when you or anyone else finds time, it can be improved.

Ondrej


1 Jul 20:49 2008

### Re: Identifying repeated subexpressions in systems of equations


On Tue, Jul 1, 2008 at 10:38, Ondrej Certik <ondrej@...> wrote:
> Any progress on this? I think it's time to make anothe release, let's
> say on Monday. If you are busy, I propose to put the code that we have
> in (with my patch and a comment how to proceed with fixing it
> generally) and when you or anyone else finds time, it can be improved.

--

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco


2 Jul 00:18 2008

### how python comparison methods (__gt__, __eq__, __cmp__, ...) work


Hi,

while thinking how to make SymPy faster, I studied how the __eq__,
__cmp__, __hash__ work, as the official Python documentation was not
at all clear to me and in the process of figuring this out I wrote
this guide:

http://docs.sympy.org/python-comparisons.html

maybe you will find it useful too. Any critical comments are welcome. :)

Ondrej


2 Jul 00:28 2008

### moving mpmath from sympy/thirdparty to sympy/


Hi,

how about moving mpmath directly to sympy/ ?
It is true that it exists as a separate project, but we deeply depend
on it and it and it contains stuff that used to by in sympy, so I view
it as a part of sympy, that can also be used separately for those who
prefer.
I would also like to copy all the docs from

to docs.sympy.org, to a separate section. And tests to
sympy/mpmath/tests. Then one can use mpmath in sympy as easy as

from sympy.mpmath import something

from sympy.thirdparty.mpmath import something.

This is also the first move to do something with the thirdparty dir.

Or do you prefer mpmath to stay in thirdparty?

Ondrej


2 Jul 00:38 2008

### Re: moving mpmath from sympy/thirdparty to sympy/


On Tue, Jul 1, 2008 at 17:28, Ondrej Certik <ondrej@...> wrote:
>
> Hi,
>
> how about moving mpmath directly to sympy/ ?

+1

--

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco


2 Jul 11:39 2008

### milion digits of pi benchmarks (sympy vs Sage)


Hi,

now when sympy can use gmpy instead of python ints if it's available,
here is a cool benchmark:

In [1]: from sympy.thirdparty.mpmath import pi, mp

In [2]: mp.dps = 10**6

In [3]: %time b = str(pi)
CPU times: user 32.17 s, sys: 0.16 s, total: 32.33 s
Wall time: 32.35 s

(You need to have the gmpy 1.03 package installed. I just created a
package for Debian and sent the maintainer of it a patch[1], so when
he applies it and uploads, it will get there.)

Compare to Sage:

sage: %time b = str(pi.n(digits=10**6))
CPU times: user 24.28 s, sys: 0.16 s, total: 24.44 s
Wall time: 24.47

So SymPy, resp. mpmath is only about 1.3 slower than Sage. Not bad at all.

I created an issue:



2 Jul 11:47 2008

### Re: milion digits of pi benchmarks (sympy vs Sage)


On Wed, Jul 2, 2008 at 11:39 AM, Ondrej Certik <ondrej@...> wrote:
> Hi,
>
> now when sympy can use gmpy instead of python ints if it's available,

I forgot to say: credit goes to casevh (comaintainer of gmpy) for
submitting a patch and Fredrik for polishing it: