#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_|  
0c93bfe4da1bd2b3a77865ae0a6878007726fff8
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Replying to [comment:13 rws]:
 > Replying to [comment:9 nbruin]:
 > > Can't you get that conversion by giving an appropriate
 `sage.symbolic.pynac.register_symbol`?
 > Is there ready mechanics for this? I can't find one. Do you expect me to
 implement it?
 No, just use it. If you do `search_src("register_symbol")` you get a few
 hits on its use. The following seems to basically work without your patch
 so I hope you can adjust it for your purposes:
 {{{
 sage: var('x,t,s')
 (x, t, s)
 sage: function('g')
 g
 sage: def swap(a,b): return g(b,a)
 sage:
 sage.symbolic.pynac.register_symbol(swap,{'maxima':'gen_harmonic_number'})
 sage: sum(1/t^2,t,1,s)
 g(s, 2)
 }}}
 That way, the parsing won't be more broken than for other functions (and
 it seems we're doing fine for most expressions nowadays). The regex for
 `psi` isn't really wrong, because it specifies there should be only digits
 between the square brackets. It is perhaps a little overly restrictive,
 though:
 {{{
 sage: psi(x,s)
 psi(x, s)
 sage: maxima_calculus(psi(x,s))
 psi[x](s)
 sage: maxima_calculus(psi(x,s))._sage_()
 TypeError: unable to make sense of Maxima expression 'psi[x](s)' in Sage
 sage: from sage.interfaces.maxima_lib import max_to_sr
 sage: max_to_sr(maxima_calculus(psi(x,s)).ecl()) #this doesn't rely on
 parsing or regexes
 psi(x, s)
 }}}
 I think "parsing" psi via regex was just a quick fix around the fact that
 the expression parser doesn't know what to do with square brackets (and
 since they're rare, you can get away with not really parsing them
 properly). In your case, round brackets are so common that you'll quickly
 get caught if you don't deal with them properly. Luckily, the parser knows
 how to deal with them, you just have to swap the arguments.

--
Ticket URL: <http://trac.sagemath.org/ticket/16671#comment:14>
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.

Reply via email to