#17445: Missing documentation of derivative operator/notation
-------------------------------+------------------------
Reporter: schymans | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.5
Component: symbolics | Resolution:
Keywords: | Merged in:
Authors: schymans | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------+------------------------
Comment (by nbruin):
Replying to [comment:4 kcrisman]:
> I don't even know whether ''any'' of those things are "really" right or
wrong at this point.
There is an internal logic that explains the behaviour. I don't think this
stuff can ever be made "intuitive" to the average calculus afficionado
because the tradition in analysis notation is just to irredeemably confuse
"function" and "function evaluated at...". Humans can handle this
confusion to some extent, but I think it's just too incompatible with how
computers represent math.
> {{{
> # 6. Fails.
> x = var('x')
> f = function('f', x)
> g = function('g', x)
> p = f.diff()
> print p.substitute_function(f, g) # Outputs "D[0](f)(x)"
> }}}
the problem: f is not a function, but a function evaluated at `x`,
whatever `x` is. I'm not going to defend that `function('f', x)` doesn't
return a function. '''THAT is the real source why this example seems
confusing'''.
{{{
sage: f
f(x)
}}}
The fact that `f.diff()` doesn't fail is apparently a heuristic, because
there's only one variable discernible in the expression. But then you see:
{{{
sage: p
D[0](f)(x)
}}}
as you can see, there's no `f(x)` appearing in that expression, so of
course substituting `f(x)` for something else has no effect. Really,
{{{
p.substitute_function(f, g)
}}}
should give a `TypeError`, because the types of the arguments don't match.
Indeed:
{{{
sage: p.substitute_function(f.operator(), g)
DeprecationWarning: Substitution using function-call syntax ...
}}}
Apparently sage does try to convert the argument `g(x)` (that is bound to
`g`) to a function.
> {{{
> # 7. Fails.
> x = var('x')
> f = function('f', x)
> g = function('g', x)
> p = f.diff()
> print p.substitute_function(f(x), g(x)) # Outputs "D[0](f)(x)"
> }}}
same problem, but even worse: `f(x)(x)` should have been deprecated
already.
> {{{
> # 8. Works.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(x).diff()
> print p.substitute_function(f, g) # Outputs "D[0](g)(x)"
> }}}
The fact that `function('f')` and `function('f',x)` return different types
of arguments is '''really''' bad. It prevents any convincing explanation
of the distinction that is essential here, because the interface
''itself'' confuses the two different issues. On top of that, we have a
lot of documentation that was written by people who were equally confused,
so the calculus doc makes a good effort to confuse any new user too.
> These are ''very'' subtle differences to anyone who is not in symbolic
algebra/expressions, and part of the issue is the difference between
expressions and functions, no doubt. So comment:1 is a good start, but
definitely only a start.
It's an entirely different issue, though. Apparently the documentation
never ''explains'' what `D[0](f)(x)` means. We can do that independent of
whether we go out of our way to confuse users about the distinction
between functions and functions evaluated at ...
--
Ticket URL: <http://trac.sagemath.org/ticket/17445#comment:6>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.