Exploring the newer GUI front-end, for use with SageMath.

One of the subjects which I had written about only yesterday, is that the Computer Algebra / Numerical Tool System called ‘SageMath‘ was available in the repositories, for Debian / Stretch – which is in itself news – and that additionally, the default way to use it under Debian is through a Web-interface called ‘SageNB’. Well what I’ve now learned is that the SageMath developers no longer support SageNB, and are continuing their work with the graphical front-end called ‘Jupyter‘.

But, installing Jupyter under Debian is a bit of a chore, because unlike how it is with custom-compiles, Debian package maintainers tend to break major software down into little bits and pieces. At one point, I had Jupyter running, but with no awareness of the existence of SageMath. What finally did the trick for me today, was to install the following packages:

  • python-notebook
  • jupyter-nbextension-jupyter-js-widgets
  • sage-math-jupyter

Needless to say, that last package out of the three is the most important, and may even pull in enough of the other packages, to be selected by itself. It’s just that I did not know immediately, to install that last package.

So this is what SageMath 7.4 looks like, through Jupyter:

screenshot_20180916_165217

(Corrected 09/18/2018, 3h50 … )

(Updated 09/18/2018, 5h40 … )

(As of 09/16/2018, 20h10 : )

Frankly, I was a bit disappointed at first. My main disappointment seemed to be with the fact, that this GUI did not offer to typeset the Math. It does allow us to ‘download’ our Notebooks as PDF-Files, but when we do, we simply get the same, highlighted text, and graphics, only as a PDF – in code – or with whatever appearance the browser-view is already showing us. Also, the support for 3D plots is lackluster, as the plot above is non-interactive. At least with SageNB, I was able to select the ‘canvas3d’ viewer, which allowed the plot to be rotated. Also, if we use SageMath from the command-line, it defaults to using ‘JMol’ as its viewer, which is full-featured.

But as it turns out, I have discovered ‘the trick’, to getting Jupyter to typeset the users’ Math…

Continue reading Exploring the newer GUI front-end, for use with SageMath.

I just installed Sage (Math) under Debian / Stretch.

One of the mundane limitations which I’ve faced in past years, when installing Computer Algebra Systems etc., under Linux, that were supposed to be open-source, was that the only game in town – almost – was either ‘Maxima’ or ‘wxMaxima’, the latter of which is a fancy GUI, as well as a document exporter, for the former.

Well one fact which the rest of the computing world has known about for some time, but which I am newly finding for myself, is that software exists called ‘SageMath‘. Under Debian / Stretch, this is ‘straightforward’ to install, just by installing the meta-package from the standard repositories, named ‘sagemath’. If the reader also wants to install this, then I recommend also installing ‘sagemath-doc-en’ as well as ‘sagetex’ and ‘sagetex-doc’. Doing this will literally pull in hundreds of actual packages, so it should only be done on a strong machine, with a fast Internet connection! But once this has been done, the result will be enjoyable:

screenshot_20180915_201139

I have just clicked around a little bit, in the SageMath Notebook viewer, which is browser-based, and which I’m sure only provides a skeletal front-end to the actual software. But there is a feature which I already like: When the user wishes to Print his or her Worksheet, doing so from the browser just opens a secondary browser-window, from which we may ‘Save Page As…’ , and when we do, we discover that the HTML which gets saved, has its own, internal ‘MathJax‘ server. What this seems to suggest at first glance, is that the equations will display typeset correctly, without depending on an external CDN. Yay!

I look forward to getting more use out of this in the near future.

(Update 09/15/2018, 21h30 : )

Continue reading I just installed Sage (Math) under Debian / Stretch.

My Distinction Between Variables And Constants

The way I process information, applied to ‘Computer Algebra Systems’, defines the difference between constants and variables in a context-sensitive way. It’s for the purpose of solving one problem, that certain symbols in an expression become variables, others constants, and others yet, function names. The fact that a syntax has been defined to store these symbols, does not affect the fact that their status can be changed from constant to variable and vice-versa.

I’ll name an example. For most purposes a Univariate Polynomial has the single variable (x), denotes powers of (x) as its base terms, and multiplies each of the base terms by a constant coefficient. To some people this might seem immutable.

But if the purpose of the exercise is to compute a Statistical, Polynomial Regression – which is “an overdetermined system” – then we must find optimal values for prospective coefficients. We can use this as the basis to form a “Polynomial Approximation” of a system, which could be of the 8th degree for example, and yet this polynomial must fit a data-set as closely as possible, which could have a list of 20 values of (x), each associated with a real value of (y), which our optimized set of coefficients is supposed to approximate, from the powers of (x), including the power (0), which always yields the base value (1).

In order to determine our 9 coefficients, we need to decide that all the powers of (x) have become constants. The coefficients we’re trying to determine best, have now become the variables in our problem. Thus, we have a column-vector of real (y)s (still variables), and matrices which state the powers of (x) which supposedly led to those values of (y). I believe that this is a standard for doing so:

Regression Analysis Guide

Well another conclusion we can reach, is that the base values which need to be correlated with real (y), aren’t limited to powers of (x). They could just as easily be some other functions of (x). It’s just that one advantage which polynomials have, is that if there is some scaling of (x), it’s possible to define a scaled parameter (t = ux) such that a corresponding polynomial in terms of (t) can do what our polynomial in terms of (x) did. If the base value was ( sin(x) ) , then ( sin(t) ) could not simply take its place. This is important to note if we are trying to approximate orbital motions of planets for example.

But then as soon as we’ve computed our best-fitting vector of coefficients, we can treat them as constants again, so that to plug in different values of (x) which did not occur in the original data-set, will also yield the corresponding, predicted values of (y’). So now (x) and (y’) are our variables again.

Dirk

 

The General Solution to a Cubic Equation

According to “Maxima”, or more specifically, according to “wxMaxima”, the three Roots to a Cubic Equation are generally as shown below, assuming that there exists one solution entirely in Real numbers:

http://dirkmittler.homeip.net/cubic.pdf

(Edit 2/7/2016 : ) There are two observations which need to be made about the solution shown above, which are related to the fact that a cubic equation can sometimes have three Real roots, or two, but that it always has at least one.

1) The expression which we’re told to find the cube root of could be equal to zero. And while finding the cube root of zero represents no obstacle, a division by zero does, and a division by zero ensues.

2) The expression we’re asked to find the square root of can become negative. In that case the solution shown above finds no Real numbers. Further, this output from ‘Maxima’ does not elucidate, how to process the fact that radicals are usually both negative and positive. An entire expression gets repeated, in which the radical could be negative. And there is no easy way to know, whether this radical is allowed to be negative in only one occurrence, or in both occurrences…

When using ‘Maxima’, a frequent goal is to eliminate extraneous complex numbers, by applying the sequence [‘rectform’, ‘trigsimp’] to an already-formed solution which is capable of producing Real numbers. But in this example, the sequence does not produce meaningful results. And one main reason is the fact that this sequence has no magic, by which to output information which was not input. So this trick does not produce an inverse-trigonometric function whose angle is naturally divided by three, so that a multiple of (2π/3) Radians could simply be added to it, before a trig function is taken again. That ‘Maxima’ can recognize.

(End of Edit 2/7/2016)

If we need to find three existing real roots, then we must apply the system of Reduction To A Depressed Cubic as shown here:

Step 1

Followed by Trigonometric Method For Three Real Roots as shown here:

Step 2