Re: [sympy] Create symbols() from a list of variables

2016-04-05 Thread theoracle
Thanks for the quick response that was good to hear, I am just getting started with Python for scientific computing and I am amazed at how powerful it is. On Monday, April 4, 2016 at 7:02:36 PM UTC-7, Amit Saha wrote: > > On Tue, Apr 5, 2016 at 11:24 AM, Aaron Meurer >

Re: [sympy] node.func.__name__ on UndefinedFunctions?

2016-04-05 Thread Nico
Great, thanks! On Tuesday, April 5, 2016 at 8:11:06 PM UTC+2, Aaron Meurer wrote: > > It works in that case too > > In [62]: u = Function('u') > > In [63]: u.__name__ > Out[63]: 'u' > > The important thing to note is that Function('u') creates *class*, not > an object. Roughly speaking,

Re: [sympy] node.func.__name__ on UndefinedFunctions?

2016-04-05 Thread Aaron Meurer
It works in that case too In [62]: u = Function('u') In [63]: u.__name__ Out[63]: 'u' The important thing to note is that Function('u') creates *class*, not an object. Roughly speaking, Function('u') is syntatic sugar for class u(Function): pass (except it also sets the metaclass as

Re: [sympy] Re: sympy.Function that returns a function

2016-04-05 Thread Aaron Meurer
If you don't need op(u) as a distinct expression that is way easier. You can also define custom printing on it to make it display however you want. Aaron Meurer On Tue, Apr 5, 2016 at 2:01 PM, Nico wrote: > Thanks Anton for the tip! > I'll see what'll work best for me.

[sympy] node.func.__name__ on UndefinedFunctions?

2016-04-05 Thread Nico
I need to get the name (as a string) of certain given functions, and I've typically done it like ``` node.func.__name__ ``` That works, except for UndefinedFunctions. Is that an oversight? How to get the 'hello' from u in ``` u = sympy.Function('hello') ``` ? Cheers, Nico -- You received this

Re: [sympy] Simplify an expression

2016-04-05 Thread Aaron Meurer
collect(expr, [a, b], func=factor) will do what you want. Also see this discussion https://groups.google.com/forum/?utm_medium=email_source=footer#!msg/sympy/-0ASBB5JBG0/1XGNURZZCAAJ. Aaron Meurer On Tue, Apr 5, 2016 at 1:45 PM, Luv Agarwal wrote: > Hey, I was trying to

[sympy] Re: sympy.Function that returns a function

2016-04-05 Thread Nico
Thanks Anton for the tip! I'll see what'll work best for me. (As a dirty workaround, I now defined the function to take two arguments, e.g., op(u, x).) Cheers, Nico -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and

[sympy] Simplify an expression

2016-04-05 Thread Luv Agarwal
Hey, I was trying to represent the following expression in more compact form: *expr = a*l**2 + 2*a*l + a + b*conjugate(l)**2 - 2*b*conjugate(l) + b* The above expr can be represented as: *expr = a*(l+1)**2 + b*(conjugate(l)-1)**2* Is there any SymPy function to perform such type of

Re: [sympy] Sympy vs Numpy, better accuracy in precision?

2016-04-05 Thread Aaron Meurer
On Tue, Apr 5, 2016 at 12:54 PM, Oscar Benjamin wrote: > On 5 April 2016 at 17:15, Aaron Meurer wrote: >> On Tue, Apr 5, 2016 at 6:19 AM, Oscar Benjamin >> wrote: >>> >>> I though that it should be possible to easily do

Re: [sympy] Sympy vs Numpy, better accuracy in precision?

2016-04-05 Thread Oscar Benjamin
On 5 April 2016 at 17:15, Aaron Meurer wrote: > On Tue, Apr 5, 2016 at 6:19 AM, Oscar Benjamin > wrote: >> >> I though that it should be possible to easily do this with sympy >> Floats but it doesn't seem to work: >> >> In [1]: x = S(1.4142) >> >>

Re: [sympy] sympy.Function that returns a function

2016-04-05 Thread Aaron Meurer
It depends if you want op(u) to also be usable in expressions. If you do, the simplest way is to make op be a Function, and define __call__ on it so that it returns an object representing op(u)(x). Defining that other object is the tricky part. I think something like class AppliedOp(Expr):

Re: [sympy] Sympy vs Numpy, better accuracy in precision?

2016-04-05 Thread Aaron Meurer
On Tue, Apr 5, 2016 at 6:19 AM, Oscar Benjamin wrote: > On 5 April 2016 at 01:56, Amy Valhausen wrote: >> >> import numpy >> (np.longdouble(1.4142)** 6000 )%400 > ... >> >> # The library mpmath is a good solution > import sympy as smp

[sympy] sympy.Function that returns a function

2016-04-05 Thread Nico
So far, I've always defined functions as ``` class f(sympy.Function): pass ``` which I could then conveniently use as ``` x = sympy.Symbol('x') y = f(x) ``` Nice. Now, I would like to define a function that itself returns a function, aka, an operator. It should be used as ``` y = op(u)(x)

Re: [sympy] Sympy vs Numpy, better accuracy in precision?

2016-04-05 Thread Oscar Benjamin
On 5 April 2016 at 01:56, Amy Valhausen wrote: > > import numpy > (np.longdouble(1.4142)** 6000 )%400 ... > > # The library mpmath is a good solution import sympy as smp mp = smp.mpmath > mp.mp.dps = 50 # Computation precision is 50 digits 50 digits is