2018-12-21 01:15:22 -0500 received badge ● Good Answer (source) 2018-09-24 08:54:46 -0500 received badge ● Notable Question (source) 2018-06-25 03:56:45 -0500 received badge ● Nice Answer (source) 2017-10-08 12:36:26 -0500 received badge ● Nice Question (source) 2017-10-08 12:36:21 -0500 marked best answer numerical_integral in piecewise function If I define a Python function with a numerical integral def g(x): var('u') return numerical_integral(u,0,x)[0]  then it behaves as expected for example when plotting with plot(g). If it is included as part of a piecewise function like f = piecewise([[(-1,0),-x],[(0,1),g]]) plot(f)  then the plot shows up just fine for Sage 6.9 (which was running on sagecell.sagemath.org), but for Sage 7.2 (which is running on the test server) one gets the error message --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in () 4 5 ----> 6 f = piecewise([[(Integer(0),Integer(1)),g]]) 7 plot(f) /home/sc_serv/sage/src/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (/home/sc_serv/sage/src/build/cythonized/sage/misc/lazy_import.c:3628)() 384 True 385 """ --> 386 return self._get_object()(*args, **kwds) 387 388 def __repr__(self): /home/sc_serv/sage/local/lib/python2.7/site-packages/sage/functions/piecewise.py in __call__(self, function_pieces, **kwds) 149 function = function() 150 else: --> 151 function = function(var) 152 function = SR(function) 153 if var is None and len(function.variables()) > 0: in g(x) 1 def g(x): 2 var('u') ----> 3 return numerical_integral(u,Integer(0),x)[Integer(0)] 4 5 /home/sc_serv/sage/src/sage/gsl/integration.pyx in sage.gsl.integration.numerical_integral (/home/sc_serv/sage/src/build/cythonized/sage/gsl/integration.c:3387)() 329 else: 330 _a=a --> 331 _b=b 332 W = gsl_integration_workspace_alloc(n) 333 sig_on() /home/sc_serv/sage/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.__float__ (/home/sc_serv/sage/src/build/cythonized/sage/symbolic/expression.cpp:10403)() 1384 return float(self._eval_self(float)) 1385 except TypeError: -> 1386 raise TypeError("unable to simplify to float approximation") 1387 1388 def __complex__(self): TypeError: unable to simplify to float approximation  Am I missing something simple or is this a bug in Sage 7.2? There is an existing ticket that appears relevant: http://trac.sagemath.org/ticket/14801 2017-10-08 12:36:21 -0500 received badge ● Nice Answer (source) 2017-09-28 17:33:39 -0500 received badge ● Nice Answer (source) 2017-07-21 11:39:24 -0500 received badge ● Popular Question (source) 2017-03-24 19:15:18 -0500 commented answer Evaluating symbolic expression, when some variables are finally fixed Needs a minor edit of V to R... 2017-03-24 17:41:35 -0500 answered a question Substitute piecewise function variable If you check the type of h with type(h), it comes back as   which is not numeric but symbolic. You can convert it to a numeric value with n(h) or h.n() and then the substitution will give zero as expected. 2017-03-24 17:27:01 -0500 answered a question label a point on a 3d graph You're looking for text3d. Documentation is here 2017-03-23 08:53:22 -0500 received badge ● Necromancer (source) 2017-03-22 18:58:49 -0500 answered a question solving a physic problem using sage Your first three equations for the balance of the components of force look fine. Your fourth equation, while accurate, is less useful than writing the tensions $S_x$ and $S_y$ as projections of the total tension $T$: $\qquad S_x = \frac{x}{\sqrt{x^2+j^2}}T \qquad S_y = \frac{j}{\sqrt{x^2+j^2}}T$ Your fifth equation is incorrect, since it says that the amount of rope on each side of the nail is always equal, which is not true for a sliding inelastic rope. If the rope is of length $L$, then the constraint you want is $\qquad y + \sqrt{x^2+j^2} = L$ If you take a second derivative of this constraint with respect to time and substitute it in the first equation, you'll have an expression for the total tension $T$ as a function of $x$ and $j$ and their derivatives. You can use that to eliminate $T$ from the second and third equations. Then you should have three coupled nonlinear differential equations for $x$, $j$ and $y$ without $T$. At that point you'll have to numerically integrate the equations as a system using for example this method. You'll need to solve for all second derivatives and then introduce intermediate variables for the first derivatives of $x$, $j$ and $y$ in order to write the system in terms of first-order equations. The problem you're trying to solve is mathematically identical to the swinging Atwood machine, but with one point of support instead of two. While it can be done in Cartesian coordinates, it will look a lot simpler in polar coordinates. Cheers! 2017-03-20 04:51:59 -0500 received badge ● Good Answer (source) 2017-03-19 15:02:53 -0500 edited answer Show Sage results in a webpage as string (not as Sagecell box) There is an existing way to use SageMathCell as a web API. It's described briefly here, but since the documentation needs improvement I'll record some information here. One way to access the API is by submitting a form to http://sagecell.sagemath.org/service (do not include a trailing slash on this URL). The documentation has a JSFiddle that I have updated for your specific example. Your command (or any other that returns a printable result) appears in a text input on the fiddle, and the output is printed below when the button is clicked. The fiddle works by URL encoding the command and posting it to the server. If you don't want to use a form, you can read the input from a text field and submit it to the server with an XMLHttpRequest. Here's some sample code that sends your URL-encoded command to the server and opens an alert window with the result: var xhr = new XMLHttpRequest(); xhr.open( 'POST', 'http://sagecell.sagemath.org/service', true ); xhr.onload = function() { var data = JSON.parse( xhr.responseText ); alert( data.stdout ); } xhr.setRequestHeader( 'content-type', 'application/x-www-form-urlencoded' ); xhr.send( 'code=P%3DPrimes()%3B+print+P.next(2016)' );  And for command line people, here's how to get the same JSON data using cURL: curl -d 'code=P%3DPrimes()%3B+print+P.next(2016)' http://sagecell.sagemath.org/service  References for SageMath as a web API came from this issue on GitHub. Thanks @novoselt! 2017-03-18 19:50:01 -0500 received badge ● Nice Answer (source) 2017-03-18 17:25:06 -0500 commented answer Error while Integrating with mathematica algorithm That's peculiar, since I don't have any errors after the fix. Did you rebuild using sage -b before running? 2017-03-18 15:55:14 -0500 answered a question Error while Integrating with mathematica algorithm The name of the website page has changed from "index.jsp" to "home.jsp". I've submitted a Trac ticket to fix that. If you know how to build Sage from source you can fix it on your copy as well or wait for Sage 8.0 (next version after soon-to-be-released 7.6). 2017-03-18 10:54:10 -0500 received badge ● Necromancer (source) 2017-03-17 15:47:03 -0500 received badge ● Nice Answer (source) 2017-03-16 18:38:37 -0500 commented question Echo input in output. I didn't realize myself that derivatives will now appear typeset if entered as fully symbolic functions, so you taught me something! As a former Mathematica user, I myself still don't quite get all the different ways Sage processes functions, symbolic or merely callable, so welcome to the club. That whole process could be made clearer. P.S. if you put square brackets around the first URL in each pair and leave the parentheses around the second URL, they should the work like proper links for future readers. 2017-03-15 15:29:45 -0500 answered a question Echo input in output. Typesetting for objects like derivatives, integrals and limits is not yet fully implemented in Sage, so the icing isn't available. You can however do something manually like this, show( "f(2)=", f(2) ) show( "f'(x)=", diff(f(x),x) ) show( "∫f(x)dx=", integrate(f(x),x) )  which gives the sort of output you want. 2017-03-15 15:00:42 -0500 answered a question Sage Math future (notebook vs cloud vs jupiter)? There is a plan to replace the legacy Sage notebook with the Jupyter notebook as of Sage 8.0, which will be the release after the next one. Here is some discussion about the change. This will bring Jupyter to the desktop along with automatic conversion of legacy notebooks. 2017-03-11 15:29:40 -0500 commented answer Integrating Log(x²+y²) The answer depends only on L^2, so the sign of L won't change anything. 2017-03-10 20:57:55 -0500 answered a question Integrating Log(x²+y²) Since the arguments of the logarithm are squared, your second integral merely reverses the order of integration compared to the first. The second integral is the negative of the first: if you add them together you'll get zero. 2017-03-09 22:51:06 -0500 received badge ● Good Answer (source) 2017-03-09 15:45:29 -0500 received badge ● Nice Answer (source) 2017-03-09 15:09:05 -0500 answered a question limit of function with dirac delta To expand on the comment by @kcrisman, limits are sent to Maxima by default. Maxima can evaluate the limit of the step function: entering unit_step(x).limit(x=0,dir='right')  returns 1 as expected. Maxima cannot evaluate the limit of the Dirac delta: entering dirac_delta(x).limit(x=0,dir='right')  returns an unevaluated expression. Since part of your limit cannot be evaluated by Maxima, it all comes back unevaluated. The other option for limit evaluation is to set algorithm='sympy': entering dirac_delta(x).limit(x=0,algorithm='sympy')  returns zero as expected. Unfortunately, entering dirac_delta(x).limit(x=0,dir='right',algorithm='sympy')  gives the message sympy does not support one-sided limits  Even more problematic, entering unit_step(x).limit(x=0,algorithm='sympy')  gives the message SymPy function 'unit_step' doesn't exist  so SymPy won't get the complete job done either. Not exactly the answer you want, but hopefully it helps you understand what's happening. 2017-03-07 15:05:22 -0500 answered a question Sage cell server dead after one request from client Some aspects of the behavior of the cell sever are designed to reduce the costs of its operation, and I would assume that applies here. If you want to know whether a change to the public server is possible, you could open an issue on https://github.com/sagemath/sagecell to get a reply from the maintainer of the server. The documentation mentioned above has moved to here. 2017-03-05 18:18:45 -0500 answered a question command line use of "?" Press q. 2017-03-01 11:18:23 -0500 received badge ● Nice Answer (source) 2017-02-27 16:14:35 -0500 commented answer Button Callbacks Answer updated 2017-02-26 15:22:27 -0500 answered a question Loaded event for sagecell There is an official callback event, but in my testing it fires long before the cell is finished processing. If you want to wait until the cell is fully displayed, you'll need to open a websocket to one of the addresses given at the beginning of this document https://github.com/sagemath/sagecell/wiki/Session and then listen for the appropriate response. The document gives sample messages for the entire process of communicating with the cell server, including interacts. 2017-02-24 16:09:45 -0500 answered a question Button Callbacks The legacy Sage notebook had JavascriptCodeButton but this was apparently not implemented in SageMathCell. The latter does have a Button element that can be used to run Python code as part of the interact: you can find an example at the beginning of this Python source file. 2017-02-24 16:06:56 -0500 answered a question Running Sage in background of site You can hide various input and output elements: see this documentation topic. You can also access the cell server as a web service and manipulate the returned JSON yourself with JavaScript. There is an extremely brief mention available, which prompted me to put together this explicit usage on my website. 2017-02-22 19:43:04 -0500 answered a question More Complex Interact Layout How about something like this (live example here): @interact(layout=[['a','b'],['t1'],['c','d'],['t2']]) def _(a=x^2, b=[1..3], c=-x ,d=[1..3], t1=text_control('Some text'), t2=text_control('Some other text') ): show(plot(a*b+c*d,0,3))  You can keep adding rows in this form of the layout. You can force the buttons closer to the input boxes by adding additional text controls after the buttons containing blank space: the automatic alignment appears to depend on the number of items in a row. 2017-02-22 19:07:40 -0500 answered a question Installation problem on Mac I'll bet you have Anaconda installed. Previous answers have indicated that removing a single line from a configuration file will allow Sage to run with Anaconda installed: Anaconda adds itself to the $PATH variable through .bashrc during installation. Removing any references to Anaconda in your $PATH should allow Sage to run. The other alternative which is known to work is to uninstall Anaconda completely. 2017-02-22 18:59:45 -0500 edited question Installation problem on Mac I followed the steps in readme.txt but when I double click on sage, it did not pop up, instead it says Last login: Wed Feb 22 13:05:21 on console MacBook-Pro/Applications/SageMath/sage ; exit; RecursionError: maximum recursion depth exceeded during compilation ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 7.5.1, Release Date: 2017-01-15 │ │ Type "notebook()" for the browser-based notebook interface. │ │ Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ ERROR: The Sage installation tree has moved from /Users/buildslave-sage/slave/binary_pkg/build/source/SageMath/jc4b6yulaujayb9sr94ia88eourzeqip0oidma to /Applications/SageMath This is not supported, and Sage will not work. To install Sage from a binary package: 1. Open the .tar.bz2 archive (or .dmg on OSX) 2. Move the SageMath folder/app to where you want it to be. You can also rename the directory now. 3. Start sage for the first time. This will then automatically patch paths in binaries. After starting Sage for the first time you cannot change the installation any more. To install Sage elsewhere, start over from the binary package. Or recompile Sage from scratch in the new location ("make distclean && make") logout Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. [Process completed]  My computer info: macOS 10.12.3 (16D32) 2 GHz Intel Core i7 The one I downloaded: sage-7.5.1-OSX_10.11.6-x86_64.dmg Has anyone encountered the same problem? 2017-02-20 04:05:37 -0500 received badge ● Necromancer (source) 2017-02-19 17:59:44 -0500 answered a question How to scale threejs graphs? As of Sage 7.5 there is a native Three.js viewer that respects aspect_ratio. You can invoke it by adding the optionviewer='threejs' to show() or any 3D object. Since the new viewer is a work in progress, feedback is welcome. 2017-02-19 17:51:44 -0500 commented answer How to find inverse laplace transform @mforets if you incorporate this into the Sage source code, the cc me and I'll review it! 2017-02-18 18:50:47 -0500 answered a question HTML with SageCellServer - Interactive Webpages It doesn't appear to be possible as of early 2017 to use HTML in SageMathCell interacts. I think this is because the software used to display code (CodeMirror) is automatically escaping the characters <, > and & that are needed to tell the browser to render content as HTML. You can however get this to work by using Unicode characters, making sure to preface the strings with u. The number of rows of buttons for L2 is controlled by the nrows option. The width option appears to be ignored by SageMathCell. I've also formatted the labels to all selectors using LaTeX, since that forces them to stay on one line. Here's some modified code: L1=[u"♕",u"♖",u"♗",u"♘",u"♙",u"♛",u"♜",u"♝",u"♞",u"♟"] L2=["a1","a3","a5","a7","b2","b4","b6","b8","c1","c3","c5","c7","d2","d4","d6","d8","e1","e3","e5","e7", "f2","f4","f6","f8","g1","g3","g5","g7","h2","h4","h6","h8"] L3=[u"Yes (Sí)","No (No)"] @interact def ChessCoords(Q1=selector(L1,buttons=True,label="$\\text{Question 1:} \\; \\text{g4}$"), Q2=selector(L2,buttons=True,label=u"$\\text{Question 2:} \\; ♗ \\,$",nrows=4), Q3=selector(L3,buttons=True,label="$\\text{Question 3:} \\;\\;\\;\\;$")): if L1.index(Q1)==0 and L2.index(Q2)==0 and L3.index(Q3)==0: pretty_print(html("")) pretty_print(html("To compute final coordinates, select your answers.")) else: pass  and here's how it looks in action. 2017-02-13 08:05:32 -0500 received badge ● Nice Answer (source) 2017-02-12 20:12:05 -0500 answered a question how to enhance this 3d implicit plot ? How about drawing the individual cylindrical sections with parametric_plot3d: var('u v') p = parametric_plot3d( [cos(u),sin(u),abs(cos(u))*v], (u,-3*pi/4,-pi/4), (v,-1,1)) p += parametric_plot3d( [cos(u),sin(u),abs(sin(u))*v], (u,-pi/4,pi/4), (v,-1,1)) p += parametric_plot3d( [cos(u),sin(u),abs(cos(u))*v], (u,pi/4,3*pi/4), (v,-1,1)) p += parametric_plot3d( [cos(u),sin(u),abs(sin(u))*v], (u,3*pi/4,5*pi/4), (v,-1,1)) p += parametric_plot3d( [cos(u),abs(cos(u))*v,sin(u)], (u,-3*pi/4,-pi/4), (v,-1,1)) p += parametric_plot3d( [cos(u),abs(sin(u))*v,sin(u)], (u,-pi/4,pi/4), (v,-1,1)) p += parametric_plot3d( [cos(u),abs(cos(u))*v,sin(u)], (u,pi/4,3*pi/4), (v,-1,1)) p += parametric_plot3d( [cos(u),abs(sin(u))*v,sin(u)], (u,3*pi/4,5*pi/4), (v,-1,1)) p += parametric_plot3d( [abs(cos(u))*v,cos(u),sin(u)], (u,-3*pi/4,-pi/4), (v,-1,1)) p += parametric_plot3d( [abs(sin(u))*v,cos(u),sin(u)], (u,-pi/4,pi/4), (v,-1,1)) p += parametric_plot3d( [abs(cos(u))*v,cos(u),sin(u)], (u,pi/4,3*pi/4), (v,-1,1)) p += parametric_plot3d( [abs(sin(u))*v,cos(u),sin(u)], (u,3*pi/4,5*pi/4), (v,-1,1)) show(p)  Live example with nice clean edges.