#13836: PiecewisePolynomial.critical_points() results depend on variable of
function
----------------------------------------------+-----------------------------
Reporter: christiankuper | Owner: burcin
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.6
Component: symbolics | Resolution:
Keywords: Piecewise, critical_points | Work issues:
Report Upstream: N/A | Reviewers: Burcin Erocal
Authors: Andrew Fleckenstein | Merged in:
Dependencies: | Stopgaps:
----------------------------------------------+-----------------------------
Comment (by christiankuper):
Hello Andrew,
thank you for the patch. It indeed seems to solve the reported problem.
However, allow me to make a few remarks:
* I am not sure whether you intentionally put the patch and the doctest
for the patch in two seperate patches
* I think the second part of your doctest does not proove anything as y is
the only variable in your PiecewisePolynomial. I can do the following:
{{{
sage: f1(y) = y^0
sage: f2(y) = 10*y - y^2
sage: f3(y) = 3*y^4 - 156*y^3 + 3036*y^2 - 26208*y
sage: f = Piecewise([[(0,3),f1],[(3,10),f2],[(10,20),f3]], y)
sage: f.critical_points()
[5.0, 12.000000000000124, 12.999999999999725, 14.000000000000151]
sage: z = var("z")
sage: g = Piecewise([[(0,3),f1],[(3,10),f2],[(10,20),f3]], z)
sage: g.critical_points()
[5.0, 12.000000000000124, 12.999999999999725, 14.000000000000151]
}}}
* From personal experience: I would avoid doctests with precion outputs
like this because they might fail due to slightly different results on 32
bit machines.
* The following modification results in an error, although e is a constant
and not a variable. However, I think this is (also) a problem related to
maxima. At least the exception raised currently is misleading. I modified
the f2 in the example above:
{{{
sage: f2(y) = e^2*y - y^2
sage: f = Piecewise([[(0,3),f1],[(3,10),f2],[(10,20),f3]], y)
sage: f.critical_points()
...
ValueError: No differentiation variable specified.
}}}
* I looked through the piecewise.py module to see whether there are other
instances of forcing the variable to x. There are indeed, but the errors
they are causing are different (see example below). Do you think it would
be sensible to deal with these cases also in this patch (as they are
related to the same root cause)? Here is an example were the output is
basically correct but the variable is wrong (g is the function defined
above):
{{{
sage: g.derivative()
Piecewise defined function with 3 parts, [[(0, 3), x |--> 0], [(3, 10), x
|--> 0], [(10, 20), x |--> 0]]
}}}
Christian
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13836#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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.