#7490: refactor symbolic functions
-------------------------+--------------------------------------------------
Reporter: burcin | Owner: burcin
Type: defect | Status: needs_review
Priority: major | Milestone: sage-4.3
Component: symbolics | Keywords: pynac
Work_issues: | Author: Burcin Erocal
Upstream: N/A | Reviewer: Mike Hansen
Merged: |
-------------------------+--------------------------------------------------
Changes (by burcin):
* status: needs_work => needs_review
Comment:
Thanks for your comments Mike.
Replying to [comment:7 mhansen]:
> Here's my review.
>
> There are a number of things which break old code -- they should be
deprecated first.
>
{{{
- exp(2,prec=100), gamma(pi,prec=100), etc.
- sage: Q.<i> = NumberField(x^2+1)
sage: gamma(i)
sage: gamma(QQbar(I))
}}}
Done:
{{{
sage: exp(2,prec=100)
...:...: DeprecationWarning: The prec keyword argument is deprecated.
Explicitly set the precision of the input, for example
exp(RealField(300)(1)), or use the prec argument to .n() for exact inputs,
e.g., exp(1).n(300), instead.
# -*- coding: utf-8 -*-
7.3890560989306502272304274606
sage: gamma(2.5, prec=100)
...:...: DeprecationWarning: The prec keyword argument is deprecated.
Explicitly set the precision of the input, for example
gamma(RealField(300)(1)), or use the prec argument to .n() for exact
inputs, e.g., gamma(1).n(300), instead.
# -*- coding: utf-8 -*-
1.3293403881791370224618731299
sage: gamma(QQbar(I))
-0.154949828301811 - 0.498015668118356*I
sage: Q.<i> = NumberField(x^2+1)
sage: gamma(i)
...:...: DeprecationWarning: Calling symbolic functions with arguments
that cannot be coerced into symbolic expressions is deprecated.
# -*- coding: utf-8 -*-
-0.154949828301811 - 0.498015668118356*I
}}}
> Conversion of polylog to maxima is broken:
{{{
sage: polylog(2, x)._maxima_init_()
'polylog(2,x)'
}}}
> instead of {{{'li[2](x)'}}}.
I don't know why I left `_maxima_init_evaled_()` commented. It works now:
{{{
sage: polylog(2, x)._maxima_()
li[2](x)
sage: polylog(4, x)._maxima_()
polylog(4,x)
}}}
> Some doctests are missing:
{{{
sage/interfaces/maxima.py: _symbolic_
sage/rings/number_field/number_field_element.pyx: _mpfr_, __complex__
}}}
Done.
> Why do you have to use
{{{
f = CallableConvertMap(RR, RR, lambda x: x.exp(),
parent_as_first_arg=False)
}}}
> instead of
{{{
f = CallableConvertMap(RR, RR, exp, parent_as_first_arg=False)
}}}
> , which is more natural?
I converted the doctest back to the original form. Return values of
`exp()` could be `int` for some inputs, even for arguments in `RR`. For
example, `exp(RR(0))` used to return an `int(1)`. I added some code to
wrap return values from GiNaC and convert them to something sensible in
`sage.symbolic.function.GinacFunction.__call__()`.
> In expression.pyx, some things are missing from the _convert docstring.
Also, f._convert(int) gives {{{-0.989992496600445*sqrt(2)}}} which seems
unexpected. Maybe the docstring can be clarified further?
I wrote a little more for the docstring and added a few examples. The fact
that GiNaC leaves the `power` objects exact is confusing, but I don't see
any easy way to get around this.
> Finally, there are some numerical issues it seems with evaluations:
complex(I) gives 0.99999999999999967j instead of 1j. I'm not sure where
the discrepancy is occurring.
This seems to be an issue with complex embeddings of number field
elements:
{{{
sage: complex(CDF.0)
1j
sage: complex(CC.0)
1j
sage: complex(CDF.0)
1j
sage: Q.<i> = NumberField(x^2+1)
sage: complex(i)
0.99999999999999967j
}}}
Of course, I added the last method that gets called for `complex(i)`, but
all it does is to `return complex(self.complex_embedding())`.
I suggest we open a separate ticket about this since it's independent of
the symbolics code and someone who knows the number field code should take
a look at it.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7490#comment:8>
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.