I'm trying to do a fairly simple task as an exercise in trying to
understand how sympy works: find the root of a transcendental
equation... This is probably some conceptual trip-up that I'm missing,
but here it is, starting from the top:
>>> from sympy import *
>>> f= Function("f")
>>> x=symbols(
On Mon, Apr 14, 2008 at 05:09:16PM -0700, [EMAIL PROTECTED] wrote:
> >>> from sympy import *
> >>> f= Function("f")
You dont need this. "f" is now a arbitary function.
> >>> x=symbols('x')
> >>> f=exp(x*x)*log(x*x)-x
And now, "f" is a sympy expression.
> >>> from sympy.numerics.optimize import
On Tue, Apr 15, 2008 at 09:08:47AM +0200, Friedrich Hagedorn wrote:
> In [27]: f=Lambda(x, exp(x*x)*log(x*x)-x)
> In [29]: f(2.0)
> Out[29]: -2 + exp(4)*log(4)
>
> I think this is not the expected behavior, but you can do
>
> In [30]: f(2.0).evalf()
> Out[30]: 73.68910751852562519599736335
>
>
I understand that there are other ways of doing this that may be
numerically more efficient, but it seems to me that the expectation
that you should be able to call a function of one variable in this
fashion (or even a function of two variables as e.g. g=x*y+x/y ;
g(4,2) ) seems like a reasonable
On Tue, Apr 15, 2008 at 09:06:45AM -0700, [EMAIL PROTECTED] wrote:
> I understand that there are other ways of doing this that may be
> numerically more efficient, but it seems to me that the expectation
> that you should be able to call a function of one variable in this
> fashion (or even a fu
For the function of two variables, the natural assumption is that
f(0,1) means x=0 and y=1 because that's alphabetical order - that's
how nearly everyone does it in the symbolic math world (just think
back to algebra and calculus courses - it's ALWAYS written in that
order, except for the occasion
On Tue, Apr 15, 2008 at 11:44:16AM -0700, [EMAIL PROTECTED] wrote:
> For the function of two variables, the natural assumption is that
> f(0,1) means x=0 and y=1 because that's alphabetical order - that's
> how nearly everyone does it in the symbolic math world (just think
> back to algebra and c
On Apr 15, 11:56 am, Gael Varoquaux <[EMAIL PROTECTED]>
wrote:
> On Tue, Apr 15, 2008 at 11:44:16AM -0700, [EMAIL PROTECTED] wrote:
> > For the function of two variables, the natural assumption is that
> > f(0,1) means x=0 and y=1 because that's alphabetical order - that's
> > how nearly everyone
On Tue, Apr 15, 2008 at 05:01:47PM -0700, [EMAIL PROTECTED] wrote:
> Well, I'm a physicist, too, and I still expect to see f(x,y,z) in that
> order... on the other hand, I also expect f(r, theta, phi) in that
> order, and that breaks all the rules, so your point is well-taken. :)
What about P(x,
On Wed, Apr 16, 2008 at 2:01 AM, <[EMAIL PROTECTED]> wrote:
>
> On Apr 15, 11:56 am, Gael Varoquaux <[EMAIL PROTECTED]>
> wrote:
>
> > On Tue, Apr 15, 2008 at 11:44:16AM -0700, [EMAIL PROTECTED] wrote:
> > > For the function of two variables, the natural assumption is that
> > > f(0,1) means
On Wed, Apr 16, 2008 at 02:08:57AM +0200, Gael Varoquaux wrote:
> On Tue, Apr 15, 2008 at 05:01:47PM -0700, [EMAIL PROTECTED] wrote:
> > > You can use lambdify, but it won't work with numpy arrays if you need
> > > functions supporting arrays (eg sin).
>
> > It isn't really the specific applicati
On Wed, Apr 16, 2008 at 01:53:30PM +0200, Friedrich Hagedorn wrote:
> > Many physicists use Mathematica to do numerical work, like you seem to be
> > wanting to do. It is not its core job, but it does it. Same thing with
> > sympy. We are just all suggesting it is not the best tool avalaible.
> O
On Apr 15, 10:06 pm, "Ondrej Certik" <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 16, 2008 at 2:01 AM, <[EMAIL PROTECTED]> wrote:
>
>
> I think secant should work with sympy functions too, not only python
> lambdas. Even if it's slow. If anyone (you?) would like to implement
> that, it'd be awesome.
On Wed, Apr 16, 2008 at 7:34 PM, <[EMAIL PROTECTED]> wrote:
>
> On Apr 15, 10:06 pm, "Ondrej Certik" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, Apr 16, 2008 at 2:01 AM, <[EMAIL PROTECTED]> wrote:
> >
> >
> > I think secant should work with sympy functions too, not only python
> > lambdas. Eve
On Thu, Apr 17, 2008 at 12:07:57AM +0200, Ondrej Certik wrote:
> > > Which variant, A or B, would you prefere? I like B because the object you
> > > want to eval is the term. And the only information sympy have to know
> > > is the order of the symbols. And further you dont need to create a
> > >
On Thu, Apr 17, 2008 at 12:07:57AM +0200, Ondrej Certik wrote:
> BTW, I think we should also implement the rest of the useful functions
> from numpy in sympy as well -- it'd be useful to have it in pure
Then I think it would be good to adjust the names:
sympy.acos <--> numpy.arccos
>From the us
On Thu, Apr 17, 2008 at 10:23:39AM +0200, Friedrich Hagedorn wrote:
>
> On Thu, Apr 17, 2008 at 12:07:57AM +0200, Ondrej Certik wrote:
> > BTW, I think we should also implement the rest of the useful functions
> > from numpy in sympy as well -- it'd be useful to have it in pure
>
> Then I think
On Thu, Apr 17, 2008 at 3:23 AM, Friedrich Hagedorn <[EMAIL PROTECTED]> wrote:
>
> On Thu, Apr 17, 2008 at 12:07:57AM +0200, Ondrej Certik wrote:
>
> > BTW, I think we should also implement the rest of the useful functions
> > from numpy in sympy as well -- it'd be useful to have it in pure
>
>
> > seems to work for me. Except the input [45], where you need to call
> > the function vectorize, e.g.:
> >
> > In [1]: term = x + x**2
> >
> > In [2]: f = Lambda(x, term)
> >
> > In [3]: f(x)
> > Out[3]:
> > 2
> > x + x
> >
> > In [4]: f(2)
> > Out[4]: 6
>
> But on the origin
On Thu, Apr 17, 2008 at 03:58:31PM +0200, Ondrej Certik wrote:
> However, how about this syntax:
> In [18]: f = Lambda(x, term, evalf=True)
Or rather f = Lamdba(x, term, numerical=True)
The reason I say this is that the keyword numerical could in the long run
be added to many functions in sympy
On Thu, Apr 17, 2008 at 03:59:32PM +0200, Gael Varoquaux wrote:
> On Thu, Apr 17, 2008 at 03:58:31PM +0200, Ondrej Certik wrote:
> > However, how about this syntax:
>
> > In [18]: f = Lambda(x, term, evalf=True)
>
> Or rather f = Lamdba(x, term, numerical=True)
>
> The reason I say this is that
On Thu, Apr 17, 2008 at 4:42 PM, Friedrich Hagedorn <[EMAIL PROTECTED]> wrote:
>
> On Thu, Apr 17, 2008 at 03:59:32PM +0200, Gael Varoquaux wrote:
> > On Thu, Apr 17, 2008 at 03:58:31PM +0200, Ondrej Certik wrote:
> > > However, how about this syntax:
> >
> > > In [18]: f = Lambda(x, term, eva
On Thu, Apr 17, 2008 at 05:09:07PM +0200, Ondrej Certik wrote:
> On Thu, Apr 17, 2008 at 4:42 PM, Friedrich Hagedorn <[EMAIL PROTECTED]> wrote:
> >
> > On Thu, Apr 17, 2008 at 03:59:32PM +0200, Gael Varoquaux wrote:
> > > On Thu, Apr 17, 2008 at 03:58:31PM +0200, Ondrej Certik wrote:
> > > > Ho
> > Well, ufuncs? Looking at the sourcecode of the Function class, maybe
> > it's as easy as adding a line checking for a list and returning a list
> > of the function
> > applied element wise. Something similar could be done for Matrices, see
> below.
>
> I dont know the ufuncs. What is the
This is why floats should be contagious, meaning that sin(2) -> sin(2)
but sin(2.0) -> 0.909297426825682. Asking for a numerical evaluation
of a function then becomes simple and intuitive. In particular,
map(sin, ) neatly gives a floating-point array
back.
Fredrik
--~--~-~--~~---
On 17 Apr., 15:58, "Ondrej Certik" <[EMAIL PROTECTED]> wrote:
> > > BTW, I think we should also implement the rest of the useful functions
> > > from numpy in sympy as well -- it'd be useful to have it in pure
> > > python and those who want speed too will just install numpy and it'd
> > > hav
26 matches
Mail list logo