Opened 5 years ago
Closed 5 years ago
#19336 closed defect (fixed)
typo in lambert_w._print_latex_()
Reported by:  rws  Owned by:  

Priority:  minor  Milestone:  sage6.10 
Component:  symbolics  Keywords:  beginner 
Cc:  kcrisman  Merged in:  
Authors:  Frédéric Chapoton  Reviewers:  Ralf Stephan 
Report Upstream:  N/A  Work issues:  
Branch:  a87b149 (Commits)  Commit:  a87b14961e31957410948c8225febed4d66c8107 
Dependencies:  Stopgaps: 
Description
From https://groups.google.com/forum/?hl=en#!topic/sagesupport/bjrk5270wEE
LaTeX output is defect.
this is probably
diff git a/src/sage/functions/log.py b/src/sage/functions/log.py index cc59437..17241ad 100644  a/src/sage/functions/log.py +++ b/src/sage/functions/log.py @@ 766,8 +766,8 @@ class Function_lambert_w(BuiltinFunction): \operatorname{W_{1}}(x) """ if n == 0:  return r"\operatorname{W_0}(%s)" % z + return r"\operatorname{W_0}({%s})" % z else:  return r"\operatorname{W_{%s}}(%s)" % (n, z) + return r"\operatorname{W_{%s}}({%s})" % (n, z) lambert_w = Function_lambert_w()
Change History (14)
comment:1 Changed 5 years ago by
 Keywords beginner added
comment:2 Changed 5 years ago by
 Cc kcrisman added
comment:3 followup: ↓ 6 Changed 5 years ago by
comment:4 Changed 5 years ago by
 Branch set to public/19336
 Commit set to 6a9b8ea4e2af1b89194237bd53ab3929684c7fa4
 Status changed from new to needs_review
New commits:
6a9b8ea  trac #19336 fixing custom latex of Lambert W function

comment:5 Changed 5 years ago by
 Status changed from needs_review to needs_work
Inserting the braces is a nice start, but it doesn't fix the entire problem. Compare:
sage: var("a1,a2") (a1, a2) sage: latex(log( (a1+a1*a2)/a2)) \log\left(\frac{a_{1} a_{2} + a_{1}}{a_{2}}\right) sage: latex(lambert_w( (a1+a1*a2)/a2)) \operatorname{W_0}({(a1*a2 + a1)/a2})
As you can see a function like "log" processes its arguments further for latex. Just inserting braces doesn't cut it.
In bessel.py, the latexing of the arguments is done explicitly:
def _print_latex_(self, n, z): return r"\operatorname{J_{%s}}(%s)" % (latex(n), latex(z))
That's probably the thing to do for lambert_w too.
comment:6 in reply to: ↑ 3 Changed 5 years ago by
Replying to vdelecroix:
What is the point of having a separate
n==0
case?
There's a case split for normal printing, suppressing a zero argument:
sage: lambert_w(0,x) lambert_w(x) sage: lambert_w(1,x) lambert_w(1, x)
Possibly the same was done for latex at some point. I agree that with the current code, the case split can be removed in the latex code.
comment:7 Changed 5 years ago by
 Commit changed from 6a9b8ea4e2af1b89194237bd53ab3929684c7fa4 to 70d9d5158e99e59566b4f4508f40c1dac0d99672
comment:8 Changed 5 years ago by
 Status changed from needs_work to needs_review
Here is a version with latex applied to the argument.
I have also taken the opportunity to enhance the link with maxima, which now has the other branches of LambertW.
comment:9 Changed 5 years ago by
ping ?
comment:10 Changed 5 years ago by
 Reviewers set to Ralf Stephan
Could you please add doctests for the Maxima additions? When done you can set positive since patchbot is already ok with it.
comment:11 Changed 5 years ago by
 Commit changed from 70d9d5158e99e59566b4f4508f40c1dac0d99672 to a87b14961e31957410948c8225febed4d66c8107
comment:12 Changed 5 years ago by
 Status changed from needs_review to positive_review
ok, I have added some doctests, hopefully corresponding to what you asked.
I set to positive review.
comment:13 Changed 5 years ago by
 Milestone changed from sage6.9 to sage6.10
comment:14 Changed 5 years ago by
 Branch changed from public/19336 to a87b14961e31957410948c8225febed4d66c8107
 Resolution set to fixed
 Status changed from positive_review to closed
What is the point of having a separate
n==0
case?