Sage: Ticket #16007: give solution constants of ODEs unique names
https://trac.sagemath.org/ticket/16007
<p>
(this was reported as part of <a class="closed ticket" href="https://trac.sagemath.org/ticket/6882" title="defect: bugs in conversion of variable names from Maxima to Sage (closed: fixed)">#6882</a>)
</p>
<p>
... solving of ode y'=c*x is not correct, the free variable is messed up with a parameter, see <a class="ext-link" href="http://groups.google.cz/group/sage-devel/browse_thread/thread/e04cbc547095f2ac"><span class="icon"></span>sage-devel</a> - thanks for Yuri Karadzhov
</p>
<pre class="wiki">sage: from sage.calculus.calculus import symbolic_expression_from_maxima_string
sage: symbolic_expression_from_maxima_string('%c')
c
sage: c=var('c'); y=function('y',x); eq=diff(y,x)==c*x; eq
D[0](y)(x) == c*x
sage: desolve(eq,y,ivar=x)
1/2*c*x^2 + c
</pre><p>
the answer should be something like 1/2*c*x<sup>2</sup> + c1
</p>
<p>
The fix depends on closing <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a>. The <code>c</code> variable that comes from Sage can then be easily recognized, and the constant <code>c</code> should then be renamed to <code>c1</code> or <code>_C1</code>.
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/16007
Trac 1.1.6kcrismanTue, 25 Mar 2014 14:29:47 GMTcc set
https://trac.sagemath.org/ticket/16007#comment:1
https://trac.sagemath.org/ticket/16007#comment:1
<ul>
<li><strong>cc</strong>
<em>kcrisman</em> added
</li>
</ul>
TicketnbruinWed, 26 Mar 2014 06:23:25 GMT
https://trac.sagemath.org/ticket/16007#comment:2
https://trac.sagemath.org/ticket/16007#comment:2
<p>
Actually, these variables are very easy to recognize any way:
</p>
<pre class="wiki">sage: function('f',x)
f(x)
sage: var('c')
c
sage: W=diff(f(x),x,x)-f(x)+c
sage: V=diff(f(x),x)-f(x)+c
sage: maxima_calculus(V).ode2(f(x),x)
'f(x)=(c*%e^-x+%c)*%e^x
sage: maxima_calculus(W).ode2(f(x),x)
'f(x)=%k1*%e^x+%k2*%e^-x+c
</pre><p>
As you can see, maxima creates these constants as <code>%c, %k1, %k2</code>, so there's no collision there. The collision only happens upon conversion back to sage. So we make the conversion more intelligent there wouldn't be an issue at all. Using <code>sage.interfaces.maxima_lib.max_to_sr</code> this would be fairly straightforward.
</p>
TicketrwsWed, 26 Mar 2014 15:45:45 GMTchangetime, time changed; branch set
https://trac.sagemath.org/ticket/16007#comment:3
https://trac.sagemath.org/ticket/16007#comment:3
<ul>
<li><strong>changetime</strong>
changed from <em>03/26/14 06:23:25</em> to <em>03/26/14 06:23:25</em>
</li>
<li><strong>branch</strong>
set to <em>u/rws/ticket/16007</em>
</li>
<li><strong>time</strong>
changed from <em>03/25/14 10:09:58</em> to <em>03/25/14 10:09:58</em>
</li>
</ul>
TicketrwsWed, 26 Mar 2014 15:47:09 GMTstatus changed; commit, author set; dependencies deleted
https://trac.sagemath.org/ticket/16007#comment:4
https://trac.sagemath.org/ticket/16007#comment:4
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>commit</strong>
set to <em>ee630f53b20aab08d094f0f9914875f30efd5e66</em>
</li>
<li><strong>dependencies</strong>
<em>#8734</em> deleted
</li>
<li><strong>author</strong>
set to <em>Ralf Stephan</em>
</li>
</ul>
<p>
Indeed, many thanks. With this easy patch the output is now
</p>
<pre class="wiki">sage: sage: x=function('x',t)
sage: sage: var('c')
c
sage: sage: desolve(diff(x,t)+2*x==t^2-2*t+c,x,ivar=t).expand()
1/2*t^2 + _C*e^(-2*t) + 1/2*c - 3/2*t + 3/4
sage: desolve(diff(f(x),x,x)-f(x),f(x))
_K2*e^(-x) + _K1*e^x
</pre><p>
Any more variables?
</p>
<hr />
<p>
New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=ee630f53b20aab08d094f0f9914875f30efd5e66"><span class="icon"></span>ee630f5</a></td><td><code>add %c,%k1,%k2 to recognized maxima objects</code>
</td></tr></table>
TicketzimmermaThu, 27 Mar 2014 09:05:56 GMT
https://trac.sagemath.org/ticket/16007#comment:5
https://trac.sagemath.org/ticket/16007#comment:5
<p>
seems to be a duplicate of <a class="closed ticket" href="https://trac.sagemath.org/ticket/9421" title="defect: desolve mixes user parameters and integration constants (closed: duplicate)">#9421</a>.
</p>
<p>
Paul
</p>
TicketrwsThu, 27 Mar 2014 10:17:46 GMT
https://trac.sagemath.org/ticket/16007#comment:6
https://trac.sagemath.org/ticket/16007#comment:6
<p>
Yes. So, are you okay with this solution applied to <a class="closed ticket" href="https://trac.sagemath.org/ticket/9421" title="defect: desolve mixes user parameters and integration constants (closed: duplicate)">#9421</a>, instead of the warning? If so, then I will make a reviewer's patch there and invalid this ticket.
</p>
TicketzimmermaThu, 27 Mar 2014 11:04:59 GMT
https://trac.sagemath.org/ticket/16007#comment:7
https://trac.sagemath.org/ticket/16007#comment:7
<p>
yes I agree with this solution, but I won't have time quite soon to check the doctests still pass.
</p>
<p>
Paul
</p>
TicketkcrismanThu, 27 Mar 2014 16:38:56 GMT
https://trac.sagemath.org/ticket/16007#comment:8
https://trac.sagemath.org/ticket/16007#comment:8
<p>
It might be worth doing a few things. First, you must have documentation testing this fix - especially since people will be confused by underscore variables without some documentation! Also, how many different things can show up? Just <code>c</code>, <code>k1</code>, <code>k2</code>, or also <code>c1</code> et al, or <code>k3</code>, ... ? It would be worth asking on the <a class="ext-link" href="http://sourceforge.net/p/maxima/mailman/maxima-discuss/"><span class="icon"></span>Maxima email list</a> about what outputs can possibly happen (assuming it's working - I was at some point subscribed to the "new" version but now am apparently not again).
</p>
<p>
But I agree it's very unlikely for anyone to have an underscore variable, so this could be a good compromise... there remains the issue of substituting in for non-Sageified variables.
</p>
TicketrwsFri, 04 Apr 2014 07:10:20 GMTstatus changed
https://trac.sagemath.org/ticket/16007#comment:9
https://trac.sagemath.org/ticket/16007#comment:9
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>needs_work</em>
</li>
</ul>
Ticketvbraun_spamTue, 06 May 2014 15:20:58 GMTmilestone changed
https://trac.sagemath.org/ticket/16007#comment:10
https://trac.sagemath.org/ticket/16007#comment:10
<ul>
<li><strong>milestone</strong>
changed from <em>sage-6.2</em> to <em>sage-6.3</em>
</li>
</ul>
TicketrwsThu, 05 Jun 2014 15:39:53 GMT
https://trac.sagemath.org/ticket/16007#comment:11
https://trac.sagemath.org/ticket/16007#comment:11
<p>
Deleted misplaced comment.
</p>
TicketrwsFri, 06 Jun 2014 08:45:00 GMTstatus changed
https://trac.sagemath.org/ticket/16007#comment:12
https://trac.sagemath.org/ticket/16007#comment:12
<ul>
<li><strong>status</strong>
changed from <em>needs_work</em> to <em>needs_review</em>
</li>
</ul>
<p>
Maxima-discuss list mail:
</p>
<pre class="wiki">On 05-06-2014 16:36, Ralf Stephan wrote:
>Sage uses Maxima to solve ODEs. To do that bug free we would
>need to know which constant vars apart from %c, %k1, %k2 are
>returned by Maxima. Can you please help?
looking at the source code of the programs in share/diffequations,
it seems to me that those 3 are the only ones. I don't know if you
have other programs in mind, apart from those in share/diffequations.
Regards,
Jaime
</pre><p>
I take it then the ticket is complete for review.
</p>
TicketkcrismanFri, 06 Jun 2014 14:35:08 GMT
https://trac.sagemath.org/ticket/16007#comment:13
https://trac.sagemath.org/ticket/16007#comment:13
<p>
Thanks for doing that due diligence. Yes, I believe these only arise from a contrib package in Maxima.
</p>
<blockquote class="citation">
<p>
I take it then the ticket is complete for review.
</p>
</blockquote>
<p>
Well... see in <a class="ticket" href="https://trac.sagemath.org/ticket/16007#comment:8" title="Comment 8">comment:8</a>
</p>
<blockquote class="citation">
<p>
First, you must have documentation testing this fix - especially since people will be confused by underscore variables without some documentation!
</p>
</blockquote>
<p>
It's really unfortunate with the underscores. But I hate to think of checking whether <code>C</code>, <code>C1</code>, <code>C2</code> etc. were defined and then using whatever the next one was. Anyway, unless Nils (who knows this stuff better than me) objects to your solution (quoting <a class="closed ticket" href="https://trac.sagemath.org/ticket/9421#comment:9" title="Comment 9 for Ticket #9421">comment:9:ticket:9421</a>)
</p>
<blockquote class="citation">
<blockquote>
<p>
(with the righter solution being: making sage's "forget the %" more intelligent, so that collisions can be avoided)
</p>
</blockquote>
</blockquote>
<p>
then as I said, this is definitely much better than leaving it 'as is'.
</p>
TicketgitSat, 07 Jun 2014 06:53:26 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:14
https://trac.sagemath.org/ticket/16007#comment:14
<ul>
<li><strong>commit</strong>
changed from <em>ee630f53b20aab08d094f0f9914875f30efd5e66</em> to <em>630ea9299705f8aa029e6ef38d8055b7c5794f52</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=1e9b54bca59e9b69cd10a08a60255012a90c4f01"><span class="icon"></span>1e9b54b</a></td><td><code>8734: more doctests fixed</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=06b952805ab10b7f30b4c06c1fcd487cbf1b7dce"><span class="icon"></span>06b9528</a></td><td><code>8734: fix doctests</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=6fffc21fbfe9a72f40f51ba22efec6dd9ec28ac5"><span class="icon"></span>6fffc21</a></td><td><code>Merge branch 'develop' into t/8734/ticket/8734-1</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=3d74cad55ddc6d1a0c64356a59c88cdac1a6f2d9"><span class="icon"></span>3d74cad</a></td><td><code>8734: rename private function, doctest it</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=3180e7b9ed36763261d579fafcb9cc67f7a887e8"><span class="icon"></span>3180e7b</a></td><td><code>Merge branch 'develop' into t/8734/ticket/8734-1</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=cec9681b1ebb379ed6eccec389981512acd527cb"><span class="icon"></span>cec9681</a></td><td><code>8734: merge conflicts</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=f70208835cb64305fc90524a9b67c5a86aed0c1e"><span class="icon"></span>f702088</a></td><td><code>take back unrelated change</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=2d31fb12b7a2932624a4ba2b310582d190d70824"><span class="icon"></span>2d31fb1</a></td><td><code>8734: doc cosmetics</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=100c8eb73d6f03b581423979f54d5c9651eed349"><span class="icon"></span>100c8eb</a></td><td><code>Merge branch 't/8734/ticket/8734-1' into t/16007/ticket/16007</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=630ea9299705f8aa029e6ef38d8055b7c5794f52"><span class="icon"></span>630ea92</a></td><td><code>16007: fix doctests; add documentation</code>
</td></tr></table>
TicketrwsSat, 07 Jun 2014 06:54:33 GMT
https://trac.sagemath.org/ticket/16007#comment:15
https://trac.sagemath.org/ticket/16007#comment:15
<p>
Merged in <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a>. Thanks for the doctest reminder.
</p>
TicketkcrismanSun, 08 Jun 2014 00:46:51 GMT
https://trac.sagemath.org/ticket/16007#comment:16
https://trac.sagemath.org/ticket/16007#comment:16
<blockquote class="citation">
<p>
Merged in <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a>. Thanks for the doctest reminder.
</p>
</blockquote>
<p>
No problem. Do you think it's useful to add an example where there might have otherwise been a collision of names, or is that superfluous?
</p>
<p>
Also, why is the doctest
</p>
<pre class="wiki">sefms('%k1*%x + %k2*%y + %c')
</pre><p>
and not
</p>
<pre class="wiki">sefms('%k1*x + %k2*y + %c')
</pre><p>
I'm not sure what the <code>%</code> is doing on the variables, though I don't doubt Sage would strip those percents off, if I recall that part of the code correctly (it's been a while, though).
</p>
TicketgitSun, 08 Jun 2014 07:07:31 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:17
https://trac.sagemath.org/ticket/16007#comment:17
<ul>
<li><strong>commit</strong>
changed from <em>630ea9299705f8aa029e6ef38d8055b7c5794f52</em> to <em>92a3fa3739fb069939c741cb310a0ba3cddad9fe</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=92a3fa3739fb069939c741cb310a0ba3cddad9fe"><span class="icon"></span>92a3fa3</a></td><td><code>16007: make doctest test intended case</code>
</td></tr></table>
TicketrwsSun, 08 Jun 2014 07:09:08 GMT
https://trac.sagemath.org/ticket/16007#comment:18
https://trac.sagemath.org/ticket/16007#comment:18
<p>
OK. Though not wrong, it wasn't what I intended, so it's changed now.
</p>
TicketkcrismanTue, 10 Jun 2014 00:17:14 GMT
https://trac.sagemath.org/ticket/16007#comment:19
https://trac.sagemath.org/ticket/16007#comment:19
<p>
I realized another question. I can't build a branch right now to check this, but I believe that in the past the <code>c</code> and friends were not only confusing, they didn't actually correspond to any Sage variable. So now we have it that there is unlikely collision, but even then we still have <code>_C</code> and friends not corresponding to any Sage variable - they haven't been injected into any namespace. (And I don't think we want to do it at startup on the off chance someone needs them.) We <em>may</em> want to do a seek-and-find for them but doing it every time could be annoying/add a little time. Anyway, at the very least that should probably be (finally!) documented if we're going to fix this.
</p>
<p>
Sorry for all the minor things occurring to me.
</p>
TicketnbruinTue, 10 Jun 2014 01:04:13 GMT
https://trac.sagemath.org/ticket/16007#comment:20
https://trac.sagemath.org/ticket/16007#comment:20
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/16007#comment:19" title="Comment 19">kcrisman</a>:
</p>
<blockquote class="citation">
<p>
I realized another question. I can't build a branch right now to check this, but I believe that in the past the <code>c</code> and friends were not only confusing, they didn't actually correspond to any Sage variable. So now we have it that there is unlikely collision, but even then we still have <code>_C</code> and friends not corresponding to any Sage variable
</p>
</blockquote>
<p>
Uh ... as soon as these make it back in sage there are symbolic variable objects that represent them. They are full-blown pynac objects right then.
</p>
<blockquote class="citation">
<ul><li>they haven't been injected into any namespace.
</li></ul></blockquote>
<p>
That has never been a requirement for objects to "exist" in sage. I don't think this is an issue at all. The objects can be accessed via <code>SR("_C")</code> as usual, and in fact if the user does <code>_C=var("_C")</code> or toplevel <code>var("_C")</code> he/she can have the object bound. We should absolutely not mess with namespaces during runtime. We <em>might</em> prebind <code>_C</code> etc. if someone thinks it's too difficult for users otherwise.
</p>
TicketrwsTue, 10 Jun 2014 04:37:22 GMT
https://trac.sagemath.org/ticket/16007#comment:21
https://trac.sagemath.org/ticket/16007#comment:21
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/16007#comment:20" title="Comment 20">nbruin</a>:
</p>
<blockquote class="citation">
<p>
We <em>might</em> prebind <code>_C</code> etc. if someone thinks it's too difficult for users otherwise.
</p>
</blockquote>
<p>
I would like to. How would I do it?
</p>
TicketnbruinTue, 10 Jun 2014 16:07:42 GMT
https://trac.sagemath.org/ticket/16007#comment:22
https://trac.sagemath.org/ticket/16007#comment:22
<p>
You can already have them predefined by putting in <code>$HOME/.sage/init.sage</code> something like:
</p>
<pre class="wiki">_C = SR.var("_C")
_K1 = SR.var("_K1")
_K2 = SR.var("_K2")
</pre><p>
Various notebook/mathcloud solutions probably expose this mechanism or something equivalent somehow.
</p>
<p>
The error people get when they do try to access these objects via the correspondingly named variables is pretty clear and they'll probably do the right thing next (they've already been able to define a differential equation in sage, so they've had to jump some hurdles already). I'd propose holding off on filling global namespace now and only consider that if it turns out to be a common complaint. The "c,k1,k2" we had before suffered the same problem and didn't generate complaints either.
</p>
TicketkcrismanTue, 10 Jun 2014 17:11:12 GMT
https://trac.sagemath.org/ticket/16007#comment:23
https://trac.sagemath.org/ticket/16007#comment:23
<blockquote class="citation">
<blockquote class="citation">
<p>
We <em>might</em> prebind <code>_C</code> etc. if someone thinks it's too difficult for users otherwise.
</p>
</blockquote>
<p>
I would like to. How would I do it?
</p>
</blockquote>
<p>
I think my point is that presumably if one then retyped the answer, or tried to use it somehow, one would get an error about an undefined variable.
</p>
<pre class="wiki">
sage: var('d')
d
sage: y=function('y',x); eq=diff(y,x)==d*x; eq
D[0](y)(x) == d*x
sage: desolve(eq,y,ivar=x)
1/2*d*x^2 + c
sage: c
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-2cd6ee2c70b0> in <module>()
----> 1 c
NameError: name 'c' is not defined
</pre><p>
That said,
</p>
<pre class="wiki">
sage: D = desolve(eq,y,ivar=x)
sage: D.subs(c=3)
1/2*d*x^2 + 3
</pre><p>
works. So I would be comfortable with very good documentation or something ahead of time - and Nils' comment indicates that better documentation for how to use these is best.
</p>
TicketgitSat, 14 Jun 2014 08:01:20 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:24
https://trac.sagemath.org/ticket/16007#comment:24
<ul>
<li><strong>commit</strong>
changed from <em>92a3fa3739fb069939c741cb310a0ba3cddad9fe</em> to <em>884bc6841811077d55a9048d616cb973e313ef24</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=884bc6841811077d55a9048d616cb973e313ef24"><span class="icon"></span>884bc68</a></td><td><code>16007: give advice how to use constants</code>
</td></tr></table>
TicketrwsSat, 14 Jun 2014 08:02:53 GMT
https://trac.sagemath.org/ticket/16007#comment:25
https://trac.sagemath.org/ticket/16007#comment:25
<p>
Please don't forget to add your names.
</p>
TicketkcrismanTue, 17 Jun 2014 12:50:57 GMTreviewer set
https://trac.sagemath.org/ticket/16007#comment:26
https://trac.sagemath.org/ticket/16007#comment:26
<ul>
<li><strong>reviewer</strong>
set to <em>Nils Bruin, Karl-Dieter Crisman</em>
</li>
</ul>
TicketrwsTue, 17 Jun 2014 12:57:42 GMT
https://trac.sagemath.org/ticket/16007#comment:27
https://trac.sagemath.org/ticket/16007#comment:27
<p>
Not positive? So what's missing?
</p>
TicketkcrismanTue, 17 Jun 2014 13:29:57 GMT
https://trac.sagemath.org/ticket/16007#comment:28
https://trac.sagemath.org/ticket/16007#comment:28
<blockquote class="citation">
<p>
Not positive? So what's missing?
</p>
</blockquote>
<p>
Still working on it! I wanted to look more closely at <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a> first. It does look okay, but I just wanted to think a little more about any unintended interactions.
</p>
TicketkcrismanTue, 17 Jun 2014 15:26:53 GMTstatus changed
https://trac.sagemath.org/ticket/16007#comment:29
https://trac.sagemath.org/ticket/16007#comment:29
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>needs_work</em>
</li>
</ul>
<p>
Is the line
</p>
<pre class="wiki">sage: from sage.calculus.calculus import symbolic_expression_from_maxima_string as sefms
</pre><p>
necessary in the doctest? Though it doesn't hurt anything.
</p>
<hr />
<pre class="wiki">sage: sefms('%k1*x + %k2*y + %c')
_K1*x + _K2*y + _C
sage: _._latex_()
'_{K_{1}} x + _{K_{2}} y + _{C}'
</pre><p>
I have a feeling this is not what we are looking for, but I don't know how to deal with it best. Presumably 'naked variables/constants' don't need to be subscripted in typesetting.
</p>
<p>
One idea, which <a class="ext-link" href="http://sagemath.org/doc/prep/Programming.html#gotchas-from-names-and-copies"><span class="icon"></span>mimics our handling of lambda</a>, would be to make the constants have names <code>k1_</code> and <code>c_</code> instead.
</p>
<pre class="wiki">sage: var('lambda_')
lambda_
sage: latex(_)
\lambda
sage: var('beta_')
beta_
sage: latex(_)
\beta
sage: var('k1_')
k1_
sage: latex(_)
\mathit{k1}
</pre><p>
Note that this is not what is desired either, since
</p>
<pre class="wiki">sage: latex(k1)
k_{1}
sage: latex(k1_)
\mathit{k1}
sage: latex(c_)
c
</pre><p>
I don't know whether this is a good solution, but we do need proper typesetting of these guys.
</p>
TicketrwsTue, 17 Jun 2014 16:18:22 GMT
https://trac.sagemath.org/ticket/16007#comment:30
https://trac.sagemath.org/ticket/16007#comment:30
<p>
Indeed. I would propose to use <code>c_</code>, <code>k_</code>, and <code>K_</code> then, because <code>%k2</code> rarely appears. Changing the behaviour of <code>latex()</code> wrt to leading underscore will open the next can of worms, like complaints about typesetting <code>_3F_1</code>.
</p>
TicketrwsWed, 18 Jun 2014 08:57:25 GMT
https://trac.sagemath.org/ticket/16007#comment:31
https://trac.sagemath.org/ticket/16007#comment:31
<p>
On the other hand, no. The best solution is in <code>latex_variable_name()</code> to recognize if a varname matches one entry of the <code>symtable</code> in <code>calculus.py</code>.
</p>
TicketgitWed, 18 Jun 2014 09:27:32 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:32
https://trac.sagemath.org/ticket/16007#comment:32
<ul>
<li><strong>commit</strong>
changed from <em>884bc6841811077d55a9048d616cb973e313ef24</em> to <em>fe2a0f0c4c536e2ad4f5fb940ce6ee7e3a1f0c22</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=fe2a0f0c4c536e2ad4f5fb940ce6ee7e3a1f0c22"><span class="icon"></span>fe2a0f0</a></td><td><code>16007: handle latexification of converted special maxima variable names</code>
</td></tr></table>
TicketrwsWed, 18 Jun 2014 09:28:01 GMTstatus changed
https://trac.sagemath.org/ticket/16007#comment:33
https://trac.sagemath.org/ticket/16007#comment:33
<ul>
<li><strong>status</strong>
changed from <em>needs_work</em> to <em>needs_review</em>
</li>
</ul>
TicketkcrismanWed, 18 Jun 2014 20:37:48 GMT
https://trac.sagemath.org/ticket/16007#comment:34
https://trac.sagemath.org/ticket/16007#comment:34
<blockquote class="citation">
<p>
On the other hand, no. The best solution is in <code>latex_variable_name()</code> to recognize if a varname matches one entry of the <code>symtable</code> in <code>calculus.py</code>.
</p>
</blockquote>
<p>
Really? But now the distinction between <code>c</code> and <code>_c</code> is lost in typesetting, if I understand this correctly, though I don't know how one would typeset the underscore in any case. I guess there probably isn't any better way, though - or? Ideas?
</p>
TicketrwsThu, 19 Jun 2014 03:12:14 GMT
https://trac.sagemath.org/ticket/16007#comment:35
https://trac.sagemath.org/ticket/16007#comment:35
<p>
Well, now there is a code point where the behaviour can be changed. So, again, is there anything missing?
</p>
TicketkcrismanTue, 24 Jun 2014 15:48:52 GMT
https://trac.sagemath.org/ticket/16007#comment:36
https://trac.sagemath.org/ticket/16007#comment:36
<blockquote class="citation">
<p>
though I don't know how one would typeset the underscore in any case.
</p>
</blockquote>
<p>
Turns out it currently just keeps the underscore.
</p>
<p>
This change could minutely slow down latex for variables that start with underscores, or if the symtable gets huge... but that is probably silly to worry about for now, neither are likely in the near future. Also may help with <a class="closed ticket" href="https://trac.sagemath.org/ticket/6882" title="defect: bugs in conversion of variable names from Maxima to Sage (closed: fixed)">#6882</a>. So I'm happy with this commit.
</p>
<blockquote class="citation">
<p>
So, again, is there anything missing?
</p>
</blockquote>
<p>
Doctest (presumably just in <code>latex_variable_name</code>) for the latexing. I realize this seems like a lot of rounds, but I've found the review process very helpful in the past, anyway. (And I'm sorry I haven't time to check out the last commit of <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a> yet.)
</p>
TicketgitWed, 25 Jun 2014 05:41:09 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:37
https://trac.sagemath.org/ticket/16007#comment:37
<ul>
<li><strong>commit</strong>
changed from <em>fe2a0f0c4c536e2ad4f5fb940ce6ee7e3a1f0c22</em> to <em>28a08aa0c6a28100d4d2e33643b0bb23b6831bb5</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=7918e732dc780ac839495d5b7fa0db2f1a4707b4"><span class="icon"></span>7918e73</a></td><td><code>Merge branch 'develop' into t/16007/ticket/16007</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=28a08aa0c6a28100d4d2e33643b0bb23b6831bb5"><span class="icon"></span>28a08aa</a></td><td><code>16007: doctest latexification; move author info to top</code>
</td></tr></table>
TicketrwsWed, 25 Jun 2014 05:43:42 GMT
https://trac.sagemath.org/ticket/16007#comment:38
https://trac.sagemath.org/ticket/16007#comment:38
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/16007#comment:36" title="Comment 36">kcrisman</a>:
</p>
<blockquote class="citation">
<blockquote class="citation">
<p>
So, again, is there anything missing?
</p>
</blockquote>
<p>
Doctest (presumably just in <code>latex_variable_name</code>) for the latexing. I realize this seems like a lot of rounds, but I've found the review process very helpful in the past, anyway. (And I'm sorry I haven't time to check out the last commit of <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a> yet.)
</p>
</blockquote>
<p>
I appreciate your thoroughness, and thanks for the review!
</p>
TicketkcrismanWed, 25 Jun 2014 13:37:43 GMT
https://trac.sagemath.org/ticket/16007#comment:39
https://trac.sagemath.org/ticket/16007#comment:39
<p>
Okay, if doctests pass (currently attempting to build the branch but it will take a while) then I'm happy with this. Thanks for working on so many symbolics/calculus things recently.
</p>
TicketkcrismanWed, 25 Jun 2014 14:07:43 GMTstatus changed
https://trac.sagemath.org/ticket/16007#comment:40
https://trac.sagemath.org/ticket/16007#comment:40
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
</ul>
TicketvbraunThu, 26 Jun 2014 02:46:57 GMTstatus changed
https://trac.sagemath.org/ticket/16007#comment:41
https://trac.sagemath.org/ticket/16007#comment:41
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>needs_work</em>
</li>
</ul>
<p>
Doctests don't pass (try <code>make ptestlong</code>)
</p>
<pre class="wiki">sage -t --long src/doc/en/tutorial/tour_algebra.rst
**********************************************************************
File "src/doc/en/tutorial/tour_algebra.rst", line 156, in doc.en.tutorial.tour_algebra
Failed example:
desolve(DE, [x,t])
Expected:
(c + e^t)*e^(-t)
Got:
(_C + e^t)*e^(-t)
**********************************************************************
</pre>
TicketkcrismanThu, 26 Jun 2014 03:13:42 GMT
https://trac.sagemath.org/ticket/16007#comment:42
https://trac.sagemath.org/ticket/16007#comment:42
<p>
Nuts!!! I could have sworn I checked everything... and now I see why long tests on <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a> are taking so long too, I did <code>make testlong</code> and not <code>make ptestlong</code>. Very sorry about this.
</p>
TicketgitThu, 26 Jun 2014 08:56:04 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:43
https://trac.sagemath.org/ticket/16007#comment:43
<ul>
<li><strong>commit</strong>
changed from <em>28a08aa0c6a28100d4d2e33643b0bb23b6831bb5</em> to <em>4add98a4e671996e859bb1c008fd61909e982c20</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=2c68026320ba3c516cd94fa1721e886ecd732804"><span class="icon"></span>2c68026</a></td><td><code>8734: adapt doctest to recent change of output</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=793bb058a06b3dfb31c6029f6c30960d1dee8cc7"><span class="icon"></span>793bb05</a></td><td><code>8734: reraise in "other" cases with bare "raise"</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=b5857b7dcbb466ca01ba720775b609953f6a0b14"><span class="icon"></span>b5857b7</a></td><td><code>Merge branch 'u/rws/ticket/8734-1' of trac.sagemath.org:sage into t/16007/ticket/16007</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=4add98a4e671996e859bb1c008fd61909e982c20"><span class="icon"></span>4add98a</a></td><td><code>16007: fix documentation examples</code>
</td></tr></table>
TicketrwsThu, 26 Jun 2014 08:59:01 GMTstatus changed
https://trac.sagemath.org/ticket/16007#comment:44
https://trac.sagemath.org/ticket/16007#comment:44
<ul>
<li><strong>status</strong>
changed from <em>needs_work</em> to <em>needs_review</em>
</li>
</ul>
<p>
Not all of <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a> was merged. Sorry for the inconvenience.
</p>
TicketvbraunThu, 26 Jun 2014 12:24:54 GMT
https://trac.sagemath.org/ticket/16007#comment:45
https://trac.sagemath.org/ticket/16007#comment:45
<p>
So has the code from <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a> been reviewed? If not make it a dependency here so I don't accidentally merge it.
</p>
TicketrwsThu, 26 Jun 2014 12:30:07 GMTdependencies set
https://trac.sagemath.org/ticket/16007#comment:46
https://trac.sagemath.org/ticket/16007#comment:46
<ul>
<li><strong>dependencies</strong>
set to <em>#8734</em>
</li>
</ul>
TicketgitWed, 02 Jul 2014 15:22:19 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:47
https://trac.sagemath.org/ticket/16007#comment:47
<ul>
<li><strong>commit</strong>
changed from <em>4add98a4e671996e859bb1c008fd61909e982c20</em> to <em>67426e10a84f9f73ad8c38d63872b3debb0f794a</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=6bfa3059f4268287392b38d0be46ec8d9c418bcb"><span class="icon"></span>6bfa305</a></td><td><code>Merge branch 'develop' into t/16007/ticket/16007</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=a195985c0617bf14a5d644f5c065bea896340ce4"><span class="icon"></span>a195985</a></td><td><code>8734: remove superfluous code</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=67426e10a84f9f73ad8c38d63872b3debb0f794a"><span class="icon"></span>67426e1</a></td><td><code>Merge branch 'u/rws/ticket/8734-1' of trac.sagemath.org:sage into t/16007/ticket/16007</code>
</td></tr></table>
TicketkcrismanWed, 02 Jul 2014 15:48:08 GMT
https://trac.sagemath.org/ticket/16007#comment:48
https://trac.sagemath.org/ticket/16007#comment:48
<p>
I am not going to check whether this passes tests, but at any rate the changes most recent seem fine, although I don't know why the non-doctest pieces had to have the constant <code>C</code> instead of <code>c</code> (but I don't really care about that). So if anyone checks it passes tests we are good here, since <a class="closed ticket" href="https://trac.sagemath.org/ticket/8734" title="defect: make sage variables unique in maxima (closed: fixed)">#8734</a> is positive review.
</p>
TicketgitThu, 03 Jul 2014 06:22:51 GMTcommit changed
https://trac.sagemath.org/ticket/16007#comment:49
https://trac.sagemath.org/ticket/16007#comment:49
<ul>
<li><strong>commit</strong>
changed from <em>67426e10a84f9f73ad8c38d63872b3debb0f794a</em> to <em>a8df107e76527d83a87456520395ab85dbc44050</em>
</li>
</ul>
<p>
Branch pushed to git repo; I updated commit sha1. New commits:
</p>
<table class="wiki">
<tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=65107d4bac54adbceb615c7bdb0af6f4ca30d93c"><span class="icon"></span>65107d4</a></td><td><code>Merge branch 'develop' into t/8734/ticket/8734-1</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=4e0738355f228ea068bea927f3025dcccb955b1c"><span class="icon"></span>4e07383</a></td><td><code>6882: add rules for e, i, I</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=e5a53435bde170e774c4e1dafba8f333a9653330"><span class="icon"></span>e5a5343</a></td><td><code>6882: do word search/replace for symtable keys</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=4c1b0eb5d6ff4b2b95487440c27c9879edb0131e"><span class="icon"></span>4c1b0eb</a></td><td><code>6882: correction to previous commit</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=518de3e62533cd209997107f903192f1a31d118c"><span class="icon"></span>518de3e</a></td><td><code>6882: add symable rules for e,i,I; fix maxima_var; add doctests</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=7a6696b714e638461cf4f77adbb65ecf413a2e4e"><span class="icon"></span>7a6696b</a></td><td><code>Merge branch 'u/rws/bugs_in_conversion_of_variable_names_from_maxima_to_sage' of trac.sagemath.org:sage into t/8734/ticket/8734-1</code>
</td></tr><tr><td><a class="ext-link" href="http://git.sagemath.org/sage.git/commit/?id=a8df107e76527d83a87456520395ab85dbc44050"><span class="icon"></span>a8df107</a></td><td><code>Merge branch 't/8734/ticket/8734-1' into t/16007/ticket/16007</code>
</td></tr></table>
TicketrwsThu, 03 Jul 2014 06:26:16 GMT
https://trac.sagemath.org/ticket/16007#comment:50
https://trac.sagemath.org/ticket/16007#comment:50
<p>
Thanks. Pulled in changes from dependencies. I'll run a patchbot on this now.
</p>
TicketvbraunTue, 08 Jul 2014 13:06:29 GMTstatus, branch changed; resolution set
https://trac.sagemath.org/ticket/16007#comment:51
https://trac.sagemath.org/ticket/16007#comment:51
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
<li><strong>branch</strong>
changed from <em>u/rws/ticket/16007</em> to <em>a8df107e76527d83a87456520395ab85dbc44050</em>
</li>
</ul>
TicketchapotonSun, 06 Sep 2015 13:08:54 GMTdescription changed; commit deleted
https://trac.sagemath.org/ticket/16007#comment:52
https://trac.sagemath.org/ticket/16007#comment:52
<ul>
<li><strong>commit</strong>
<em>a8df107e76527d83a87456520395ab85dbc44050</em> deleted
</li>
<li><strong>description</strong>
modified (<a href="/ticket/16007?action=diff&version=52">diff</a>)
</li>
</ul>
Ticket