Feeds:
Posts

## Posts Tagged ‘C++’

I’ve been trying Sage(math) for the last three weeks, and I can say it’s a charming piece of software. Works very well, the IRC channel is really, really helpful, the interface is simple, the Python platform is rather natural to manage, evolves quickly… and so on.

However, there are some weak points I’d like to comment…

• Documentation: Since Sage(math) use about 70 different applications, the documentation is FAR of being complete. It would be useful if the documentation is improved, at least if it refers to, say, Maxima documentation… or Numpy… etc.
• Hypergeometric Functions: Besides the confluent one, the hypergeometric functions are left behind. I guess the problem is the maxima support of Special Functions.
• Browser Integration: There are still some weak points in browsers other than firefox… like Chromium-browser. A.f.a. I know, Chromium has problems opening new worksheets, and with some permissions settings.

So, I recomend using firefox as the main browser for Sage(math) and if possible integrate it with other calculation programs like Maple or Mathematica. And finally look up further into Maxima, and other pieces of Sage documentation, as well as using the IRC channel (#sage-devel) an google groups for asking questions.

## Installing and Using SageTeX.

A few minuted ago I could install and use the sagetex package for Sage(math). I’d like to thank ElMonkey for helping me via the IRC channel #sage-devel.

## Pre-requisites.

It is assumed that you have installed

• A LaTeX compiler,
• A LaTeX editor,
• and Sage(math)

all of them configured and working properly.

Get the last version of the package in http://www.sagemath.org/packages/optional/.

## Installing the Package.

My Sage script is located in a sub/sub/sub/subfolder/Sage-4.3.1 (from my HOME folder), so when I want to running it, I should type

$sub/sub/sub/subfolder/Sage-4.3.1/./sage It isn’t nice to repeat this one and again, every day. Thus, I created an alias. Open the .bashrc file in your editor (gedit for example) $ gedit .bashrc


add (at the end of the file) the line

alias sage='/path/to/your/sage/folder/./sage'


which in my example would be,

alias sage='/home/doxdrum/sub/sub/sub/subfolder/Sage-4.3.1/./sage'


Save and close the editor. Now in the terminal,

$source .bashrc  and from now on I just type $ sage

for running the program.

### The real installation.

Now, type in the terminal

$sage -i sagetex-2.2.1.spkg and that’s it. ## Configuration. After the installation, a new folder is placed into the Sage folder. Look into local/share/texmf. All files (and folders) inside it must be copied to the LaTeX tree. In a Linux distribution the LaTeX tree should be placed in /usr/share/texmf/tex/latex $ sudo cp -r /path/to/Sage-4.3.1/local/share/texmf \
/usr/share/texmf/tex/latex
$sudo mktexlsr /usr/share/texmf/tex/latex This should work. However, if it doesn’t… the desperate method is to copy the sagetex.sty from /path/to/Sage-4.3.1/local/share/texmf to the folder of the TEX file. ## The TeX File. It is time to create a file.tex, just as any other TEX file. Add the line \usepackage{sagetex} to the preable. ### Compiling the TeX file. When you run $ pdflatex file.tex

the compilator exits with errors… but you get a file.sage, sage-compile it and run pdflatex again,

$sage file.sage$ pdflatex file.tex


There it is!!!

A resume compilation line could be

$pdflatex file.tex && sage file.sage && pdflatex file.tex Enjoy it! Read Full Post » ## My first Sage(math) page Yesterday I add my first contribution to sagenb.org/pub. This has a couple of applications of the Euler method for solving ODE’s (ordinary differential equations. Check it out at my sage notebook Read Full Post » # Adding a Calculation Line. For adding a calculation line between other two lines, pass the pointer between them and click the narrow line that appears close to the bottom line. # Text in the Notebook. When you call the notebook from the terminal, it appear as a calculation line. If you’d like to add text, press the Shift-key when adding a new line where the text would be placed. NOTE: you can add math LaTeX symbols as usual surrounded by dollar symbols. # LaTeX Text. When you add text in the work-sheet, It look more like OOfice than LaTeX. If in the calculation line you introduce the text precede by a line containing %latex  when you evaluate’ the line, the LaTeX text would appear as result. I do not know if it’s possible to drop the text in the command line after its evaluation. # Editing a Work-Sheet. For editing a worksheet, 1. Click the button Edit in the Upper-Right corner of the notebook page. 2. In the text-like mode appearing erase the lines you’d like to drop. 3. Save the changes (in the button over the first text line). 4. Return to the Worksheet-mode. Another way (easier for small editing) 1. Erase the text in the calculation line you want to drop 2. In the empty line click the Backspace-key. Thanks to the people in the IRC channel #sage-devel. Read Full Post » About 10 days now I started to use Sage(math) for my calculations… I must admit I was (and still am) really impress for it reliability and easy use. However, since my default web browser is not Firefox, the notebook of sage opens in Chromium-browser (which is neither my default browser, but conkeror). The problem with Chromium-browser was that it did not auto-complete… but now it does, so if you’re using Chromium-browser the tab-key now helps you to auto-complete the sage command. Read Full Post » You can put your Sage commands in a file with extension “.sage”. That’s a Sage script. You run this script as: $ sage /path/to/myscript.sage

Thanks to mvngu for this useful information, as well as his original post!

If you plot a function,

sage: p = plot(sin(x), (x, -3, 3), axes_labels=['$x$', '$\\sin(x)$']; p

and want to save it in a given directory (without showing it) as a JPG file, then use

sage: p = plot(sin(x), (x, -3, 3), axes_labels=['$x$', '$\\sin(x)$'];
p.save(filename = '/path/to/your/directory/file.jpg')

NOTE: it is possible to save the plots as PDF, PNG and EPS.

I was interested in plotting a set of functions depending on a discrete parameter $n$, and save them with an useful name, say file-i.jpg for $n=i$, so the solution is,

sage: for n in range(1,4): p = plot(x^n, (x, -4, 4));
p.save(filename = '/path/file-%s.jpg' %(n))

If there are more parameters, i.e. $m, n$, change the last part as follows,

'file-%s-%s.jpg' %(m,n)`

I found the above trick extremelly useful! Hope you do too.