Feeds:
Posts
Comments

Posts Tagged ‘Python’


If you have programmed in Python, perhaps you would know IPython.

IPython is an interactive shell for python programming.

Installing IPython

In the terminal (Ctrl+Alt+T), run the command line

$ sudo apt-get install -y ipython ipython-notebook

and after entering your sudo password, IPython will be installed.

Command to install IPython

Command to install IPython

Running IPython

In the terminal, launch the command

$ ipython
Command to Call the Ipython session

Command to Call the Ipython session

and you will have you session running.

Initial Ipython session

Initial Ipython session

More about IPython in a next post!!! (specially about the notebook) 😉

Cheers, and enjoy life!

Read Full Post »


Last weekend, I wrote a program in SAGE that list all possible irreps of a Lie group, one specified the group (in Cartan’s classification) and the maximum sum of the Dynkin labels.

Check the notebook in here.

Since I’m not a programmer, please feel free to leave comments, specially if you find ways to optimize the program

Cheers,

DOX

Read Full Post »


Sage beginner’s guide is a book by  Craig Finch, published recently by PACKT publishing.

After spending two weeks looking at different aspects of the book, I can say with property that this is an excellent book, an I’ll recommend it for beginners to medium experienced SAGE users.

Since this is the first book I review, and also the first I own from this publisher, I’d say that its format is quite understandable, and one might learn a lot by following examples… and then, just then, the details are explained. I really love that feature of the writing.

The first chapter, called What can we do with Sage?, shows in about 20 pages some powerful tools available in Sage, from symbolic calculation, linear algebra, ODE’s, to plotting functions in 2D and 3D… even fitting of curves.  I’ll say this is an impressive chapter, and it’s just the start point. Nonetheless, as in any book, one might notice that in some examples the graphics do not correspond to the code, but when you try the code yourself, you get the right ones.

The chapter about Installing Sage, is written in detail, and explain how to install the software in the three major operative systems: Windows, X OS, and Linux. Of course, due to the unstoppable develop of open source software, there’s a delay in the version shown in the book, however, the steps to follow are the same. A nice thing is that it’s explained how to compile the source for multi-core systems.

Getting Started with Sage, shows a huge amount of small tricks, I mean… I’ve been using Sage for about one a half year, and had no idea of plenty of the tricks explained in this chapter. Awesome!!!

All aspects of Sage are exploited, command line, notebook, different cells in the notebook, all the different types of variables available… and their operations. Functions and even a quick introduction to object oriented programming.

Another useful chapter of the book is the one where some differences (and similarities) between Sage and Python are explained. As a example, the use of commands like range, xrange or srange.

Chapters 5 to 8 show with plenty examples and incredible detail uses of Sage in linear algebra, visualization (plotting), symbolic and numerical calculation. Of course, there is no way I can explain how vast the content is, but include:

  • Simplifications in symbolic calculation,
  • Manipulation and analysis of data,
  • Integral transforms,
  • Differential equations,
  • Series,
  • Differential and integral calculus,
  • Numerical calculus, et cetera.

Finally, the last two chapters are more a complement for intermediate users, specially with programming knowledge. They cover python programming, say functions, classes and modules, and its uses, and more advanced features of Sage as \LaTeX integration, optimization of numerical calculation (with NumPy and Cython), and an introduction to the interactive mode.

Thus, In a scale from zero to ten I’d give a 9/10 to this book, because managing such a variety of tricks and functions are worth it.

 

You can check out the book at http://www.packtpub.com/sage-beginners-guide/book

Read Full Post »


In case you wanna explore with parallel python, the web page is
http://www.parallelpython.com/

Installation in Linux (debian based):

* download the tarball, say to your home folder
* in a console type:

$ cd
$ tar xzf pp-1.6.1.tar.gz
$ cd pp-1.6.1/
$ sudo python setup.py install

* it should be installed in just one sec.
* for testing it, run the program in the example page,

$ python sum_primes.py

Dox.

P.D.: My results

Usage: python sum_primes.py [ncpus]
[ncpus] – the number of workers to run in parallel,
if omitted it will be set to the number of processors in the system

Starting pp with 2 workers
Sum of primes below 100 is 1060
Sum of primes below 100000 is 454396537
Sum of primes below 100100 is 454996777
Sum of primes below 100200 is 455898156
Sum of primes below 100300 is 456700218
Sum of primes below 100400 is 457603451
Sum of primes below 100500 is 458407033
Sum of primes below 100600 is 459412387
Sum of primes below 100700 is 460217613
Time elapsed: 3.31923294067 s
Job execution statistics:
job count | % of all jobs | job time sum | time per job | job server
9 | 100.00 | 6.4885 | 0.720947 | local
Time elapsed since server creation 3.32604193687

Read Full Post »


In a previous post we discuss the definition of the coordinated patch on a manifold, how to define differential forms, wedge them or calculate their exterior derivative… even simplify’em.

This time a zero form will be defined and a list of forms will be created… So, let’s begin!

Define a 0-form

Once created the coordinated patch and the differential forms algebra

sage: reset()
sage: var('t,x,y,z')
sage: U = CoordinatePatch((t,x,y,z))
sage: Omega = DifferentialForms(U)

A 0-form is defined as an element of \Omega^0(U), but the value of the 0-form is given inside the declaration command,

sage: A = DifferentialForm(Omega, 0, exp(x*y))

I tried addition, multiplication, wedge product and exterior differentiation on 0-forms and they worked!

Of course you can combine them with forms of different degrees.

New method of defining a form

I wrote to Joris this morning… but before he was able to answer, from the documentation of the differential form package.

When one calls the generators of the differential form,

sage: Omega.gen(1)
dx

and the result is a differential form… Thus, one can assign a form as follow,

sage: A = sin(x)* Omega.gen(2)
sage: B = cos(y) * Omega.gen(0)
sage: C = sin(z) *Omega.gen(1)
sage: D = cos(y) * Omega.gen(2)

And this forms can be wedged, differentiated, et cetera. 🙂

List of forms

Finally, after discovering the above behavior I tried the following, a list of differential forms ;-), for example,

sage: pro = matrix([[A, B], [C, D]])
sage: for i in range(2):
...       for j in range(2):
...           show(pro[i,j].diff())

returns
cos(x)dx\wedge dz
sin(y)dx\wedge dy
-cos(z)dy\wedge dz
-sin(y)dy\wedge dz

This implies that somehow one can manage a series of forms by using list properties… I expect to go deeper on this subject in the future! 😀

Enjoy people!!!

Dox

Read Full Post »

Older Posts »

Design a site like this with WordPress.com
Get started