I don't see why every SymbolicExpression should be callable. In usual
mathematical practice this not
assumed, and expressions like  x(3)  are avoided or interpreted as 3x
(=3*x). Only when it is clear that
a symbolic name is a function name (like f,g) does function
application become the default. If I read in a paper:

"Let $f:R\to R$ be defined by $f = x^3+x+1$."

I would consider this a (fairly harmless) typo, since the author
surely meant "...defined by $f(x) = x^3+x+1$."

This distinction between variable names and function names could be
implemented
via another symbolic expression subtype for "FunctionExpression".

e.g.

function_var("f,g")      # or maybe fvar("f,g")
f(x) = x^3 + x + 1   # equivalent to: f = lambda x: x^3 + x + 1
f(1)

Out: 3

(f+g)(x)

Out: f(x)+g(x)

f+x

Out: Error: don't know how to add FunctionExpression and
SymbolicExpression

(f^3)(x)

Out: f(f(f(x)))

x(10)

Out: Error: SymbolicExpression is not callable

For undergraduates this behavior might be less confusing than having
expressions like
x(x+1) be silently misinterpreted as x+1.

--Peter


On Nov 5, 8:55 pm, Robert Dodier <[EMAIL PROTECTED]> wrote:
> William Stein wrote:
> > Would you consider this weird if you read it in a paper, or
> > would you know how to interpret it?
>
> >   "Let $f = x^3 + x + 1$ and consider $f(10)$."
>
> I'm not so sure I know what to do with that.
>
> I'm pretty sure I want (x^3 + x + 1)(10) to be (x^3)(10) +
> x(10) + 1(10). (If the last term were y instead of 1, I'd
> probably want y(10).)
>
> About x(10), I might want that to be x, 10, 10*x, or let
> it remain x(10).
>
> About (x^3)(10), I might want that to be x(x(x(10))) or (x(10))^3.
>
> I might want 1(10) to be 1. I probably want x(10) to yield
> the same as 1(10) if I substitute 1 for x.
>
> These considerations lead to different interpretations, most of
> which differ from the way Sage implements callable expressions,
> if I'm not mistaken. I don't see a need for Sage to preempt
> useful and interesting interpretations. Under the circumstances,
> the right thing to do is to postpone function evaluation until
> additional context is supplied.
>
> FWIW
>
> Robert Dodier
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to