Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operands and Operator of symbolic expressions #10169

Open
simon-king-jena opened this issue Oct 25, 2010 · 4 comments
Open

Operands and Operator of symbolic expressions #10169

simon-king-jena opened this issue Oct 25, 2010 · 4 comments

Comments

@simon-king-jena
Copy link
Member

I think that for all symbolic expression s should hold

sage: s == s.operator()(*s.operands())

That currently does not work, for two reasons.

  1. There may be no operator at all:
sage: print x.operator()
None
sage: x.operands()
[]

I believe there should instead be an identity operator.

  1. The list of operands may be longer than what the operator accepts:
sage: s = 0.001*x^2+0.01*x+0.1*sin(1.01*x)+1
sage: s.operands()
[0.00100000000000000*x^2, 0.0100000000000000*x,
0.100000000000000*sin(1.01000000000000*x), 1]
sage: s.operator()(*s.operands())
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call
last)

/home/king/<ipython console> in <module>()

TypeError: op_add expected 2 arguments, got 4 

Compare this thread at sage-devel.

CC: @eviatarbach

Component: symbolics

Keywords: operator operands symbolics

Issue created by migration from https://trac.sagemath.org/ticket/10169

@simon-king-jena

This comment has been minimized.

@eviatarbach
Copy link

comment:4

Note to self: after this is fixed (or at least just the arithmetic operators), simplify_hypergeometric should be added to simplify_full. Now it cannot be added because it will sometimes raise errors due to this bug.

@eviatarbach
Copy link

comment:5

Burcin, is there a problem with setting the sum operator to Expression.add, for example? I don't understand why we have to define new functions representing the arithmetic operators.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@rwst
Copy link

rwst commented Feb 27, 2015

comment:10

This will not work with some symbolic functions because they may have been called with the hold=True keyword, and calling them again doesn't know about it. See also #17849. The solution of that ticket in line with this one would be to make keywords into operands (strings?, a dedicated class OperatorKeyword?).

Another possible solution would be to abandon the hold keyword and introduce a hold context, see #10035.

@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants