Ask Your Question

paulmasson's profile - activity

2022-05-31 15:33:43 +0200 received badge  Good Answer (source)
2021-11-09 02:58:02 +0200 received badge  Good Answer (source)
2021-11-06 23:45:18 +0200 received badge  Nice Answer (source)
2021-07-06 15:02:37 +0200 received badge  Famous Question (source)
2021-02-22 22:52:45 +0200 commented question plot3d shows a black window

Please let us know what error messages appear in the JavaScript console for both Firefox and Chromium when you try loading a graphic.

2020-08-08 01:37:55 +0200 commented question plot3d displaying black graph in jupyter for both 9.0 and 9.1

Can you get the plot to work with viewer=“jmol”?

2019-11-25 13:48:00 +0200 received badge  Taxonomist
2019-10-09 21:45:15 +0200 answered a question macOS Catalina does not allow launching Sage app

There should be an option in System Preferences > Security & Privacy to open any downloaded app. Follow the instructions at the very bottom of this web page.

2019-10-08 22:57:18 +0200 answered a question Hypergeometric Bug?

Sage uses mpmath for numerical evaluation. The documentation for the underlying function says explicitly:

If a nonpositive integer −n appears in both a_s and b_s, this parameter cannot be unambiguously removed since it creates a term 0 / 0. In this case the hypergeometric series is understood to terminate before the division by zero occurs. This convention is consistent with Mathematica.

I have confirmed that Mathematica gives the same answers as Sage. Apparently Maxima chooses a different convention, so be aware of this.

2019-09-13 00:17:44 +0200 commented answer jmol stuck at "Initializing 3D display"

I'd also like to know what outstanding major problems there are with the Three.js viewer. Please add them to #22408 at your convenience.

2019-07-01 11:51:31 +0200 received badge  Nice Answer (source)
2019-07-01 03:06:30 +0200 answered a question Numerical integration and plot failing

Here’s a workaround for plotting:

list_plot( [[t, F(t)] for t in (1,1.1..2)], plotjoined=True )

with a live example. For integration you could likewise evaluate the function at discrete points, add all interior evaluations plus half of the values at the endpoints and multiply by the step size (i.e., a discrete integral).

2018-12-21 08:15:22 +0200 received badge  Good Answer (source)
2018-09-24 15:54:46 +0200 received badge  Notable Question (source)
2018-06-25 10:56:45 +0200 received badge  Nice Answer (source)
2017-10-08 19:36:26 +0200 received badge  Nice Question (source)
2017-10-08 19:36:21 +0200 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)
<ipython-input-1-474c66ac1c47> in <module>()
      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:

<ipython-input-1-474c66ac1c47> 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*> 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 19:36:21 +0200 received badge  Nice Answer (source)
2017-09-29 00:33:39 +0200 received badge  Nice Answer (source)
2017-07-21 18:39:24 +0200 received badge  Popular Question (source)
2017-03-25 01:15:18 +0200 commented answer Evaluating symbolic expression, when some variables are finally fixed

Needs a minor edit of V to R...

2017-03-24 23:41:35 +0200 answered a question Substitute piecewise function variable

If you check the type of h with type(h), it comes back as

<type 'sage.symbolic.expression.Expression'>

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 23:27:01 +0200 answered a question label a point on a 3d graph

You're looking for text3d. Documentation is here

2017-03-23 14:53:22 +0200 received badge  Necromancer (source)
2017-03-23 00:58:49 +0200 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 10:51:59 +0200 received badge  Good Answer (source)
2017-03-19 21:03:47 +0200 edited answer 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-03-19 21:02:53 +0200 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-19 01:50:01 +0200 received badge  Nice Answer (source)
2017-03-18 23:25:06 +0200 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 21:55:14 +0200 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 16:54:10 +0200 received badge  Necromancer (source)
2017-03-17 21:47:03 +0200 received badge  Nice Answer (source)
2017-03-17 00:38:37 +0200 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 21:29:45 +0200 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 21:00:42 +0200 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 22:29:40 +0200 commented answer Integrating Log(x²+y²)

The answer depends only on L^2, so the sign of L won't change anything.

2017-03-11 03:57:55 +0200 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-10 05:51:06 +0200 received badge  Good Answer (source)
2017-03-09 22:45:29 +0200 received badge  Nice Answer (source)
2017-03-09 22:09:05 +0200 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 22:05:22 +0200 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-06 01:18:45 +0200 answered a question command line use of "?"

Press q.

2017-03-01 18:18:23 +0200 received badge  Nice Answer (source)
2017-02-27 23:14:35 +0200 commented answer Button Callbacks

Answer updated

2017-02-27 23:14:28 +0200 edited answer 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.