Opened 9 years ago

Last modified 8 years ago

#11888 closed defect

Sage is missing the lambert_w function conversion from Maxima — at Version 3

Reported by: benjaminfjones Owned by: burcin
Priority: minor Milestone: sage-5.1
Component: symbolics Keywords: lambert_w symbolics conversion maxima sd35.5 sd40.5
Cc: kcrisman, ktkohl Merged in:
Authors: Benjamin Jones Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by kini)

Maxima returns solutions to some exponential equations in terms of the lambert_w function. Sage is missing a conversion for this function:

sage: solve(e^(5*x)+x==0, x, to_poly_solve=True)
[x == -1/5*lambert_w(5)]
sage: S = solve(e^(5*x)+x==0, x, to_poly_solve=True)
sage: z = S[0].rhs()
sage: z
sage: N(z)
TypeError                                 Traceback (most recent call last)

/Users/jonesbe/sage/sage-4.7.2.alpha2/devel/sage-test/sage/<ipython console> in <module>()

/Users/jonesbe/sage/latest/local/lib/python2.6/site-packages/sage/misc/functional.pyc in numerical_approx(x, prec, digits)
   1264             prec = int((digits+1) * 3.32192) + 1
   1265     try:
-> 1266         return x._numerical_approx(prec)
   1267     except AttributeError:
   1268         from sage.rings.complex_double import is_ComplexDoubleElement

/Users/jonesbe/sage/latest/local/lib/python2.6/site-packages/sage/symbolic/ in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17950)()

TypeError: cannot evaluate symbolic expression numerically
sage: lambert_w(5)
NameError                                 Traceback (most recent call last)

/Users/jonesbe/sage/sage-4.7.2.alpha2/devel/sage-test/sage/<ipython console> in <module>()

NameError: name 'lambert_w' is not defined

mpmath can evaluate the lambert_w function, so it should be easy to add a new symbolic function to Sage that will fix this issue.


  1. trac_11888.patch to $SAGE_ROOT/devel/sage
  2. trac_11888-doctests.patch to $SAGE_ROOT/devel/sage

Change History (5)

comment:1 Changed 9 years ago by kcrisman

  • Cc kcrisman added

Changed 9 years ago by benjaminfjones

add lambert_w symbolic function

comment:2 Changed 9 years ago by benjaminfjones

  • Authors set to Benjamin Jones
  • Keywords sd35.5 added
  • Status changed from new to needs_review

Preliminary patch needs review. The function has been added using the template developed as part of #11143. The issue described in the description is addressed in one of the doctests.

Changed 9 years ago by kini

apply to $SAGE_ROOT/devel/sage

comment:3 Changed 9 years ago by kini

  • Description modified (diff)

Running make ptestlong now. I fixed a couple of doctests that broke, and fixed some typos and rST syntax problems in your docstring.

Note: See TracTickets for help on using tickets.