#14270: Remove function call syntax for symbolic expressions
-----------------------------------------+----------------------------------
Reporter: ppurka | Owner: burcin
Type: defect | Status: needs_work
Priority: major | Milestone: sage-5.9
Component: symbolics | Resolution:
Keywords: | Work issues: fix
combinat/tutorial.py
Report Upstream: N/A | Reviewers:
Authors: Punarbasu Purkayastha | Merged in:
Dependencies: | Stopgaps:
-----------------------------------------+----------------------------------
Changes (by ppurka):
* work_issues: fix doctests => fix combinat/tutorial.py
Comment:
I am able to fix all the doctests except for the following one in
combinat/tutorial.py.
The example which fails seems to make no sense to me. A
`substitute_function` method is being used to substitute a function with a
symbolic expression.
{{{
sage: C, z = var('C,z');
sage: sys = [ C == z + C*C ]
sage: sol = solve(sys, C, solution_dict=True); sol
[{C: -1/2*sqrt(-4*z + 1) + 1/2}, {C: 1/2*sqrt(-4*z + 1) + 1/2}]
sage: s0 = sol[0][C]; s1 = sol[1][C]
...
sage: C = s0; C
-1/2*sqrt(-4*z + 1) + 1/2
...
sage: equadiff
(4*z - 1)*D[0](C)(z) - 2*C(z) + 1 == 0
sage: Cf = sage.symbolic.function_factory.function('C')
sage: equadiff.substitute_function(Cf, s0) # Original answer is the
deprecation + answer
...
TypeError: %d format: a number is required, not NoneType
}}}
Let us try to "fix" this (`z` is a symbolic variable). Somehow the
following works (beats me why it does):
{{{
sage: equadiff.substitute_function(Cf(z), s0)
(4*z - 1)*D[0](C)(z) - 2*C(z) + 1 == 0 # OK, so this seems to work
}}}
But now the next command in the tutorial gives `False` instead of `True`
{{{
sage: bool(equadiff.substitute_function(Cf(z), s0))
False
}}}
Why is all this happening? Looking at the documentation of
`substitute_function` shows that it should be used for substituting
''functions'', not anything else
{{{
def substitute_function(self, original, new):
"""
Returns this symbolic expressions all occurrences of the
function *original* replaced with the function *new*.
}}}
And what exactly are we substituting above?
{{{
sage: type(Cf)
sage.symbolic.function_factory.NewSymbolicFunction
sage: type(s0)
sage.symbolic.expression.Expression
}}}
We are substituting a symbolic function with a symbolic expression! How
was this even working earlier?
What should I do with this portion of the tutorial? Delete this?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14270#comment:3>
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.