#16671: implement harmonic number function H(n,m)
-------------------------------------+-------------------------------------
Reporter: rws | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.3
Component: symbolics | Resolution:
Keywords: special, log | Merged in:
Authors: Ralf Stephan | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/rws/implement_harmonic_number_function_h_n_m_|
ebc93ecacf652b5b83077ba20c22b37f8178ca78
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
A few remarks.
- in the `maxima_harmonic` regular expression you seem to be trying to
find the argument by matching subexpressions. I'm afraid that won't work
reliably. If you put in arguments that use parentheses and commas itself
and you'll find the regex gets it wrong. Indeed, the example you've taken
it from is equally broken:
{{{
sage: maxima_calculus(psi(psi(x,x),x))._sage_()
TypeError: unable to make sense of Maxima expression 'psi[psi(x,x)](x)' in
Sage
}}}
(never mind that this is a ValueError and not a TypeError). The maxima_lib
specific translator does not have trouble with this:
{{{
sage: max_to_sr(maxima_calculus(psi(psi(x,x),x)).ecl())
psi(psi(x, x), x)
}}}
Regular languages are not sufficient to describe expression languages (the
nested parentheses can't be expressed in a regular language--they need a
stack or something similar). Can't you get that conversion by giving an
appropriate `sage.symbolic.pynac.register_symbol`? then you get to use the
parentheses parser that is already in place.
- for this line, you took a way too complicated example.
{{{
sage.functions.log.harmonic_number : lambda N,X : [[mqapply],[[max_harmo,
max_array],X],N],
}}}
from
{{{
sage: maxima_calculus("gen_harmonic_number(a,b)").ecl()
<ECL: (($GEN_HARMONIC_NUMBER SIMP) $A $B)>
}}}
you see that this should simply be
{{{
sage.functions.log.harmonic_number : lambda N,X : [[max_harmo],X,N],
}}}
With your version one gets:
{{{
sage:
maxima_calculus(EclObject([["mqapply"],[["$gen_harmonic_number","array"],10],20]))
gen_harmonic_number[10](20)
}}}
which is not the desired form, and you'll find this form can't be
converted back either.
--
Ticket URL: <http://trac.sagemath.org/ticket/16671#comment:9>
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.