ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 05 Feb 2020 18:34:42 +0100Sagemath 9.0 Markdown inconsistency Cocalc vs. Localhttps://ask.sagemath.org/question/49808/sagemath-90-markdown-inconsistency-cocalc-vs-local/I have recently installed the latest Sagemath 9.0 on a Windows 10 machine and noticed a Markdown bold formatting problem that is not present on the Cocalc.com Sagemath 9.0 version. Here is the Markdown:
For each of the 10 questions a student can choose 1 of **3** possibilities: (1) answer T, (2) answer F, or (3) omit. By the **Extended Rule of Products**, there are $3^{10}$ ways of accomplishing this, this is far more than $2^{10}$.
On the local 9.0 install it renders as:
![image description](https://snipboard.io/7rRdcU.jpg)
Notice that the bold is not terminated by the ** after the '3'. On the other hand, the same code on Cocalc.com renders correctly with Sagemath 9.0:
![image description](https://i.snipboard.io/Rqr05O.jpg)
Both of these use the latest Chrome browser. Is there any way to correct the Markdown rendering on the local install?
If Sagemath provides the Jupyter notebook for CoCalc is it possible for them to provide the SAME Jupyter notebook with their binary downloads for windows and other platforms? Or just update the Jupyter notebook part of the Sagemath 9.0 Windows executable?holistoneWed, 05 Feb 2020 18:34:42 +0100https://ask.sagemath.org/question/49808/How to copy notebook worksheet data from one computer to anotherhttps://ask.sagemath.org/question/26844/how-to-copy-notebook-worksheet-data-from-one-computer-to-another/ Hi, I have a number of sage notebook worksheets in my old ubuntu laptop. I need to get a copy of them to my new ubuntu laptop as well as to another win8.1 laptop. Need to work with then locally without internet connection in my boat, so it's a critical issue for me.simoSat, 16 May 2015 17:34:21 +0200https://ask.sagemath.org/question/26844/error using minimize_constrainedhttps://ask.sagemath.org/question/8861/error-using-minimize_constrained/When I use minimize_constrained(), I get the following error:
File "", line 1, in <module>
File "/tmp/tmp81ftcX/___code___.py", line 72, in <module>
minimize_constrained(T, [_sage_const_1 ], nil)
File "/sagenb/sage_install/sage-4.8-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/numerical/optimize.py", line 415, in minimize_constrained
return vector(RDF,min)
UnboundLocalError: local variable 'min' referenced before assignment
It comes from the following piece of code:
K = matrix(K) # matrix of size (3*N+1)*(3*N+1)
des = vector(des) # vector of size 3*N+1
u = vector([var("u%02d" % k) for k in [0..3*N]]) # size 3*N+1
def LHS(X):
Y = 0.5*K*X*X - vector(des)*X
return Y
nul = [0 for j in range(0,3*N+1)]
minimize_constrained(LHS(u), [u02 -1], nil)
I don't understand why I keep getting the error for above function call (I know about global/local variables in python function calls, but definition of vector "u" makes it's elements global variables.)bennisonFri, 06 Apr 2012 10:56:27 +0200https://ask.sagemath.org/question/8861/Piecewise assumptions (for integration)https://ask.sagemath.org/question/8710/piecewise-assumptions-for-integration/All right, still with these integration problems, and I don't know all the subtleties of passing extra-arguments to Maxima (ok, I reckon that @kcrisman doesn't stop pointing out Maxima flags now and then when some expert uses them but some list would be very handy).
What I want is to integrate a function with the domain of integration broken into pieces. The problem is that the maxima engine requires different assumptions for each piece but an assumption seems to tie a variable globally.
**Example**: In fact, this example is still related to the [double integral thread over there](http://ask.sagemath.org/question/1077/symbolic-expectations-and-double-integrals). After a little but tedious pen and paper work, I could get rid of the absolute value by breaking the domain of integration into pieces but then I'm stuck again. Independently of my own shortcomings and maybe the hard nature of what I tried to compute, in my sense, the remaining problem causes are mainly twofold, we need to talk to Maxima (pass assumptions) and the assumption mechanisms in Sage are somehow weak.
This is what I tried to get around these shortcomings and to answer the above question:
# This could take extra-arguments for the integral function (algorithm, ...) but I don't know all of them, so let's leave this as is for now.
def integral_assumptions(f, var, lbound, ubound, extra_assumptions):
old_assumptions= assumptions() # Keep current assumptions for later restore
assume(extra_assumptions)
result = integral(f, var, lbound, ubound)
forget()
assume(old_assumptions) # Unfortunately, extra assumptions don't stay local
return result
Different problems arise:
1- If the integral call breaks (and this often occurs), the old_assumptions are not restored .. ok, this one should be easy and dealt with some exception handling but I don't know the Sage coding guideline here.
x,y,u,v,p,k,b=var('x,y,u,v,p,k,b') # It seems enough to just say var('x,y,u,v,p,k,b') but I'm not sure
n(x)=1/sqrt(2*pi) * exp(-1/2*x^2) # I would have loved to be able to get this directly from Maxima but okay, it was just a few keystrokes away.
# I need to split at -sqrt(k-1)*v
alpha_neg(v,k,p)=integral_assumptions((u)^p*(u+sqrt(k-1)*v)^p*n(v)*n(u), u, 0, -sqrt(k-1)*v, [k-1 > 0, v < 0])
integral(alpha_neg(v, k, p), v, -oo, 0) # Error
alpha_neg(v,k,2) # Still an error but just to find the culprit
2- One **big** problem is the way Sage handles assumptions: they are global and (but maybe that *feature* is because of the fact that ...) they can't be made more stringent. Namely `assume(x>=0); assume(x>0)` doesn't yield x>0. It would have also been handy to be able to say forget(x>0) and it would give back x>=0 and have a forget_about(x) function which forgets everything about x ..
To be clear, I'm not against global assumptions but I just want some way to enforce extra assumptions locally.
3- Another bonus feature would have been the possibility of attaching a set of assumptions to an expression/function/whatnot. In fact I started with:
#inner_neg as we're on the part where v<0.
inner_neg(v, k, p, i_lo, i_hi)=integral_assumptions((u)^p*(u+sqrt(k-1)*v)^p*n(v)*n(u), u, i_lo, i_hi, v < 0)
g(v,k)=inner_neg(v, k, 1, 0, oo) # -sqrt(k-1)*v) # Ok with oo
If I instead ask with `-sqrt(k-1)*v`, Maxima again complains about vGreen diodSun, 12 Feb 2012 19:29:54 +0100https://ask.sagemath.org/question/8710/