Showing posts with label Math Software. Show all posts
Showing posts with label Math Software. Show all posts

Wednesday, February 8, 2012

Ubuntu 11.10 - update on a few things from me

Ok, so I installed Ubuntu 11.10 on a few of my computers at school and have noticed a few things.

First, it seems that Ubuntu finally updated its repositories in the USC to reflect the latest wxMaxima version which is 11.04.



I also noticed that is seems synaptic package manager is slowly becoming obsolete.  I could install it, but I couldn't run it while the USC was open.  So I decided to install my wanted extra TeX Live packages from the USC instead.  It worked pretty well.


I am also cutting down on software packages, especially for math/science.  I have cut off the simple graphing and calculating software such as KAlgebra, Libniz, Euler, etc., and I am sticking mainly with wxMaxima and Sage.  I am also trying to get into Python.

Thursday, February 2, 2012

mlab — matplotlib.mlab

mlab — Matplotlib v1.1.0 documentation
Numerical python functions written for compatability with MATLAB commands with the same names.

Tuesday, January 31, 2012

SymPy - Python library for symbolic mathematics

http://sympy.org/en/index.html

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries.


Sage - 2D plot - simple plot, more than one function on the same plot, axes limits, change color of function in graph

There are many options when plotting in Sage.  Here is a simple example.

alpha = 30*pi/180
show(alpha)
show(float(alpha))
f = (arcsin(alpha))^2 + log(tan(alpha/2)) - arcsin(alpha)*arctan(alpha)
show(f)
show(float(f))
g = (1/(0.7*sin(x)))*sqrt(1 + ((pi)^(-2))*((0.7*sin(x))^2)*(f - csc(x)*tan(x/2) - log(tan(x/2))))
p = plot(g, (0, alpha))
show(p, ymin = 0, ymax = 20)

In Sage, the variable x is automatically known/defined.  I then create a simple function similar to how I created alpha and f.  I next equal p to the plot since I wanted to change the y axis range manually which you can do through the show command (or this can also be done in the plot command as well).



Here is another example of a 2D plot.  This one shows how to plot a couple of functions.

alpha = 30*pi/180
show(alpha)
show(float(alpha))
z = 0.5
r_max = z*tan(alpha)
show(r_max)
show(float(r_max))
lamb_da = (csc(alpha))^2 - (cot(alpha))*(csc(alpha)) + log(tan(alpha/2))
show(float(lamb_da))
cig_ma_c = 1
r = var('r')

psee = (1/2*pi)*(cig_ma_c)*(r^2)*(lamb_da + (z/r)*sqrt(1 + (z/r)^2) - log(sqrt(1 + (z/r)^2) - z/r) - 1 - (z/r)^2)

lamb_da_bi = (csc(alpha))^2 - (cot(alpha))*(csc(alpha)) + log(tan(alpha)/2)

show(float(lamb_da_bi))

psee_bi = (1/2*pi)*(cig_ma_c)*(r^2)*(lamb_da_bi + (z/r)*sqrt(1 + (z/r)^2) - log(r/(2*z)) - 1 - (z/r)^2)

p1 = plot(psee, (r, 0, r_max))

p2 = plot(psee_bi, (r, 0, r_max), color ='green')

show(p1 + p2)



Sage - displaying a float decimal point

In Sage, like many other mathematics software, uses either a float command or you can simply put a "." in your value to display decimals.

f = (arcsin(alpha))^2 + log(tan(alpha/2)) - arcsin(alpha)*arctan(alpha)
show(f)
show(float(f))

Screenshot:


Monday, January 30, 2012

Sage - Declaring a value

So first things first.  I simply want to declare a value for something.  In this case I want alpha to equal some number.

alpha = 30*pi/180

show(alpha)

Hit evaluate and it gives: (1/6)*pi It works!


Installing Sage for Windows 7


This is a pretty cool mathematical program/software which is kind of like a combination of MATLAB/Octave, Mathematica, Maple, Maxima, etc.  They even say that as a description.  I've mentioned Sage before, but now I am going to really give it a go.  To install for Windows 7 simply go here  http://wiki.sagemath.org/SageAppliance and follow the instructions.  First you will need to DL and install VirtualBox, though, here https://www.virtualbox.org/wiki/Downloads and DL the Windows Sage appliance here  http://www.sagemath.org/download-windows.html.

Here are my earlier posts about Sage:

http://timothyandrewbarber.blogspot.com/2011/08/sage-open-source-mathematics-software.html

http://timothyandrewbarber.blogspot.com/2011/08/pre-built-binary-install-sage.html <-- Ubuntu install

http://timothyandrewbarber.blogspot.com/2011/08/sage-in-emacs-and-tex.html

Sunday, January 29, 2012

Maxima and wxMaxima in Windows 7

I am forced to use Windows every now and then, but I have recently found out that some of my favorite software works for Windows and is relatively easy to install.  Maxima is very easy, as you just download and run the Windows installer from here:  http://www.windows7download.com/win7-maxima/kqcjkmcz.html

Installing Maxima for Windows also installs wxMaxima (and Xmaxima if wanted) and gnuplot.  Here is a screenshot.


Monday, December 26, 2011

Differentiation in Maxima

Mathematica is a great piece of software.  You can do many things with it mathematically.  However, it is not free and not always available.  I am trying to find some replacements that are free, cross-platform, readily available, relatively easy to use.

I have been trying at Maxima using the wxMaxima interface and have been quite pleased with it.  So far I have been able to graph functions related to my research.  However, Mathematica is pretty powerful as you can do differentiation, integration, etc. with ease.  Just recently, I tried the differentiation ability of Maxima.  It is possible to do differentiation in Maxima.  So far I have only tried a simple polynomial.  The command for differentiation is:

diff(expr, x)

Here is a screen shot of some examples I did.


Now if I could figure out if and how to simplify the last expression.  If Maxima can do that, then it is a very viable option to Mathematica for several things.

I found this differentiation command at http://mathandmultimedia.com/tag/maxima-tutorial/

Update:  So as you might have noticed I got a great tip in the comments on how to simplify this fraction.  The tip comes from Mike Croucher who has a great, insightful blog http://www.walkingrandomly.com/ which I must admit I don't read often enough due to time but check it out anyways.  It is well established and post similar topics yet more advanced and involved examples.


Friday, December 23, 2011

Legendre polynomials of the first kind, plots of degrees n = 0, 1, 2, 3, 4, 5

\( P_0 \left( x \right) = 1 \)


\( P_1 \left( x \right) = x \)


\( P_2 \left( x \right) = \dfrac{1}{2} \left( 3 x^2 - 1 \right) \)


\( P_3 \left( x \right) = \dfrac{1}{2} x \left( 5 x^2 - 3 \right) \)


\( P_4 \left( x \right) = \dfrac{1}{8} \left( 35 x^4 - 30 x^2 + 3 \right) \)


\( P_5 \left( x \right) = \dfrac{1}{8} x \left( 63 x^4 - 70 x^2 + 15 \right) \)





\( P_0 \left( x \right), P_1 \left( x \right), P_2 \left( x \right), P_3 \left( x \right), P_4 \left( x \right), P_5 \left( x \right) \)





Code for last graph in wxMaxima:

plot2d([legendre_p(0, x), legendre_p(1, x), legendre_p(2, x),legendre_p(3, x), 
legendre_p(4, x), legendre_p(5, x)], [x, -2, 2], [y, -2, 2], 
[legend,"P_0 (x) = 1","P_1 (x) = x","P_2 (x) = (1/2)*(3*x^2 - 1)",
"P_3 (x) = (1/2)*x*(5*x^2 - 3)","P_4 (x) = (1/8)*(35*x^4 - 30*x^2 + 3)",
"P_5 (x) = (1/8)*x*(63*x^4 - 70*x^2 + 15)" ], [ylabel,"P_n (x)"], [gnuplot_preamble,"set key bottom"]);

Saturday, November 26, 2011

sin(x) + cos(x)


\( \sin x + \cos x \)

Code for Maxima:

f(x) := sin(x) + cos(x)
plot2d(f(x), [x, 0, 7], [y, -2, 2]);


sin(x) - cos(x)


\( \sin x - \cos x \)

Code for Maxima:

f(x) := sin(x) - cos(x)
plot2d(f(x), [x, 0, 7], [y, -2, 2]);


Friday, November 25, 2011

tan(x)


\( \tan x \)

Code for Maxima:

plot2d(tan(x), [x, 0, 7], [y, -2, 2]);


sin(x) + cos(x)


\( \sin x + \cos x \)

Code for Maxima:

plot2d(sin(x)+cos(x), [x, 0, 7]);


Bessel function of the second kind, orders 0, 1, 2



\( Y_0 \left( x \right) \)

Code to plot in wxMaxima:
plot2d(bessel_y (0, x), [x, 0, 20], [y, -2, 1]);


\( Y_1 \left( x \right) \)

Code to plot in wxMaxima:
plot2d(bessel_y (1, x), [x, 0, 20], [y, -2, 1]);


\( Y_2 \left( x \right) \)

Code to plot in wxMaxima:
plot2d(bessel_y (2, x), [x, 0, 20], [y, -2, 1]);


\( Y_0 \left( x \right), \quad Y_1 \left( x \right), \quad Y_2 \left( x \right) \)

Code to plot in wxMaxima:
plot2d([bessel_y (0, x), bessel_y (1, x), bessel_y (2, x)], [x, 0, 20]);



Bessel functions of the first kind, orders 0, 1, 2

Since Lybniz only recognizes the python standard math library, I used wxMaxima to plot the Bessel functions.

\( J_0 \left( x \right) \)

Code to plot in wxMaxima:
plot2d(bessel_j (0, x), [x, 0, 20]);



\( J_1 \left( x \right) \)

Code to plot in wxMaxima:
plot2d(bessel_j (1, x), [x, 0, 20]);


\( J_2 \left( x \right) \)

Code to plot in wxMaxima:
plot2d(bessel_j (1, x), [x, 0, 20]);


\( J_0 \left( x \right), \quad J_1 \left( x \right), \quad J_2 \left( x \right) \)

Code to plot in wxMaxima:
plot2d([bessel_j (0, x), bessel_j (1, x), bessel_j (2, x)], [x, 0, 20]);


Bessel function syntax in Maxima

The commands for Bessel functions in Maxima are:

Bessel function 1st kind: \( J_n \left( x \right) \)
bessel_j (index, expr)

Bessel function 2nd kind: \( Y_n \left( x \right) \)
bessel_y (index, expr)

Modified Bessel function 1st kind: \( I_n \left( x \right) \)
bessel_i (index, expr)

Modified Bessel function 2nd kind: \( K_n \left( x \right) \)
bessel_k (index, expr)

http://maxima.sourceforge.net/docs/manual/en/maxima_15.html

Thursday, November 24, 2011