Tuesday, September 10, 2013

sagemath terminal colours - green > blue

Sagemath includes an embedded version of ipython and any changes you make to terminal colours need to happen in ipython_config.py in the correct place.

After doing a sage install there is a directory on my computer at location:

The goal of this short set of hints is to assist you in creating a suitable profile_sage/ipython_config.py file.

That file should look like this:

# Configuration file for ipython.

c = get_config()

# Set the color scheme (NoColor, Linux, or LightBG).                                                                    
c.TerminalInteractiveShell.colors = 'Linux'

What that will achieve is to make your prompt green instead of blue.
The default (blue) seems a little bright on the eyes, so by setting colors = 'Linux' you get the less garish green prompt instead.

You can just run ahead and use geany or another editor to create ipython_config.py with content detailed above.

If you prefer to look at what iPython itself generates then you might wish to know of these two commands:
  • ipython profile list
  • ipython profile create justcreatedbyme
However be aware that you want to be running the embedded ipython version when doing 'profile create' in order to be sure a a fully compatible profile is created.
( Manual copy / rename things to get file to proper location of
profile_sage/ipython_config.py )

An example of the output from profile list is shown below:

List of profiles available to iPython

Thursday, June 27, 2013

Power of negative number - pari gp

Do use parentheses () to wrap your negative where necessary.

Because exponentiation has priority over +/- you should wrap your -1 in parentheses (), or, if just squaring, use the sqr() function.

The priority of operators in Pari/GP is detailed in Section 2.4 of the User Guide and titled "2.4 GP Operators"

Sunday, January 20, 2013

number of digits function - sage - sagemath

If you work with Sage a lot, then these two points will help you remember how to get a digit count:
  • Sage uses Objects to represent mathematical constructs
  • Sage is written in Python

Answer: 1067

There are 1067 digits in the number formed when 11 is raised to 1024

Pari/GP and number of digits:

In Pari/GP the length() function can be used in a similar way to len() in Sage. In Pari try length(Str(11^1024))

You can still access Pari/GP directly through sage.

Try this in Sagemath:


The very large - two examples using Pari:

( click on the image above for optimal font sizing )

Notes and further reading:

You can check the 11^1024 digit count yourself by following this wolfram alpha link:

Python note: Although sage allow you to use ^ to indicate raising to power, when writing in Python directly you should use the correct ** operator.
Pari/GP is designed particular for number theory, and does not have a real need to store mathematical constructs as api friendly Objects [by default] in the same way as Sage does.