Links | Octave | R | TI Calculator | Maxima | WolframAlpha | GeoGebra | Sage | Latex

Octave

What is Octave?

Matlab has become a standard in scientific computing. It is a high-level numerical computing language, and can be used as both a programming language and command-line driven calculator. Matrices are the basic objects of computation.

Matlab is proprietary software, and can be quite expensive for some of the more state-of-the-art special toolboxes. Octave is a free and open-source clone of Matlab. It has essentially the same syntax and functionality, but is open-source and free!

Reference Links

Installing Octave

Octave is installed on selected lab computers, but you are strongly encouraged to install this software on your own PC.
  1. Download the installer and save it to your Desktop.
  2. Double-click on the file you just downloaded to begin the installer.
  3. Agree to the license and all default settings.
  4. Your install is now complete, and you should have a shortcut to Octave on your desktop and in your start menu. You can delete the original installer.

Matlab/Octave Quick Introduction

The Matlab user environment is just a plain console, where you can type commands and receive answers. Think of it as a specialized calculator, with the power to solve much larger and varied types of problems. Use the resource links above, in conjunction with the built-in 'help' command to see how a particular function works. The examples below will demonstrate some basic Matlab commands; you should experiment with them on your own.
  • The up/down arrows conveniently allow you to scroll between previous commands.
  • Put a semicolon at the end of a command to suppress output.
  • Variables are case-sensitive.
  • The example commands/output below should be self-explanatory.

>> A=[1 5 0 1000; 0 -3 1 200; 1 0 -1 0]
A =
         1         5         0      1000
         0        -3         1       200
         1         0        -1         0

>> size(A)
ans =
        3        4

>> A(1,4)
ans = 1000

>> A(2,:)
ans =
         0        -3         1       200

>> A(:,2)
ans =
         5
        -3
         0

>> B=A(1:3,1:3)
B =
         1         5         0
         0        -3         1
         1         0        -1

>> B'
ans =
         1         0         1
         5        -3         0
         0         1        -1


>> A([2,3],:)=A([3,2],:)
A =
         1         5         0      1000
         1         0        -1         0
         0        -3         1       200

>> rref(A)
ans =
        1        0        0      500
        0        1        0      100
        0        0        1      500
>> A\b
ans = 
      500
      100
      500

>> inv(A)*b
ans = 
      500
      100
      500
sum a series

S=0; for k=1:100,   S = S + 1/k;   end; S
recursive sequence

B=[0];
for k=1:40
  B(end+1) = 1.05*B(end) + 5500; 
end
printf("%2d %12.2f\n",[0:40;B]);
plot(0:40,B,'+')
plot contours/surfacex = -8:.1:8;
y = -8:.1:8;
[X,Y]=meshgrid(x,y);
Z = sin(sqrt(X.^2+Y.^2)) ./ sqrt(X.^2+Y.^2);
mesh(Z);
contour(Z);
meshc(Z);

R Statistics Software

What is R?

R is a free open-source statistical software package. Think of it as a calculator on steroids. It has a command-line interface, and can serve as a programming language. It can do simulations, graphs, and analysis on data that you enter yourself, or download from the web.

References

Installing R

R is installed on selected lab computers, but you are strongly encouraged to install this software on your own PC.
  1. Download the exe file and save it to your Desktop.
  2. Double-click on the file you just downloaded to begin the installer.
  3. Agree to the license and all default settings.
  4. Your install is now complete, and you should have a shortcut to R on your desktop and in your start menu. You can delete the original installer.
  5. If you use a Mac or Linux, you can find install info here.

R Quick Introduction

  • These commands illustrate some basic R functionality.
  • The up/down arrows conveniently allow you to scroll between previous commands.
  • Put a semicolon at the end of each command.
  • Variables names are case-sensitive.
  • A data set may have multiple columns - to access one column use "datasetName$columnName"

q(); quit R
ctime = c(10,45,5,10,7,7);define data set vector
ctime; show the data set
length(ctime); length of the data set
class = read.table("m:/m201/class.txt",header=T); read data set as a table from a file
summary(class$siblings); 1-var summary data
sd(class$siblings); standard deviation
stem(class$shoe); stem and leaf plot
barplot(table(class$siblings)); histogram
hist(class$shoe,freq=F); histogram of quantitative data
boxplot(class$shoe); boxplot
boxplot(class$shoe ~ class$gender); parallel boxplots
seq(1,100,2) list 1 to 100 by 2's
sample(1:30, 7); sample without replacement
sample(1:30, 7, replace=T); sample with replacement
rnorm(10, mean=100, sd=15); sample from normal distribution
x = matrix( sample(1:0,7*20, replace=T, c(.6,.4)), ncol=7);
totals = rowSums(x);
simulate binomial (20 sims, n=7, p=.6)
n = 6; sims = 100;
x = matrix( rexp(n*sims, 1/4), ncol=n);
sampleMeans = rowSums(x) / n;
simulate sampling dist of xbar
prop.test(30, 50, p=.5, conf.level=.95, alternative="two.sided") one sample proportion test
t.test(class$shoe, mu = 10, conf.level=.95, alternative="two.sided") t-test on sample mean

TI 83/84 Calculator

enter dataSTAT-EDIT; fill in data vals in L1, and optionally frequency in L2
restore lost listSTAT-5-ENTER
One variable summarySTAT-CALC, 1VarStats L1 (,L2)
factorial5 [[math , prb , ! ]]
permuation5 [[ math, prb, nPr ]] 2
combination5 [[ math, prb, nCr ]] 2
binomial for exactly xbinompdf(n, p, x)
binomial for less than or equal to xbinomcdf(n, p, x)
full binomial distributionbinompdf(n,p) [ -> L2 ]
normal for x between a and bnormalcdf(a,b,mu,sigma) (use +/- E99 for infinity)
normal distribution, given a percentile area A, find xinvnorm(A,mu,sigma)
conf int / hyp test for proportionSTAT-TESTS-1-PropZInt/Test
conf int / hyp test for sample meanSTAT-TESTS-TInterval/Test
conf int / hyp test for 2-sample proportionSTAT-TESTS-2-PropZInt/Test
conf int / hyp test for 2-sample meanSTAT-TESTS-2-SampTInt/Test
hyp test for standard deviationsSTAT-TESTS-2-SampFTest
linear regression / correlationenter data in L1,L2, and then STAT-TESTS-LinRegTTest
ANOVAenter data in L1,L2,L3,etc, and then STAT-TESTS-ANOVA(L1,L2,L3)
chi-squared test for independenceenter contingency table in MATRIX-EDIT, then STAT-TESTS-chi^2

Maxima

end a commandsemi-colon
submit commands for processingshift-enter
get a numerical approximation22/7, numer;
float(22/7)
define a variablec:7;
clear a variablekill(c);
define a functionf(x):=x^2; f(2);
built-in constants%e, numer; %pi, numer;
integrateintegrate(x^2,x,0,3);
integrate numericallyquad_qags(x^2,x,0,3);
make a sequencemakelist([n,1/n],n,1,10);
find a limitlimit((n+1)/n,n,inf);
sum a seriessum(1/k^2, k, 1, inf), simpsum;
Taylor seriestaylor(exp(x), x, 0, 8);
parametric plotplot2d ([parametric, cos(t), sin(t), [t, 0, 2*%pi], [nticks,100]]);
parametric plotload(draw);
draw2d(parametric(cos(t),sin(t),t,0,2*%pi));
draw3d(parametric(cos(t),sin(t),t,t,0,2*%pi));
animated plotload(draw);
r(t):=[cos(t),sin(t)];
Tmin:0; Tmax:4*%pi; n:50;
with_slider_draw(
T, makelist(Tmin+i*(Tmax-Tmin)/n,i,0,n),
xrange = [-2,2], yrange = [-2,2],grid=true,dimensions=[600,500],
label([printf(false,"t=~8,3f",T),0,0]),
parametric(r(t)[1],r(t)[2],t,0,T) ,
point_size=2,point_type=filled_circle,color=red, points([r(T)]) );
polar plotload(draw);
draw2d( user_preamble="set grid polar",
color=red,line_width=2,xrange=[-4,4],yrange=[-3,3],nticks=300,
polar(4/theta,theta,1,6*%pi));
3d surface plotload(draw);
draw3d(enhanced3d=true,surface_hide=true,xu_grid=50,yv_grid=50,xlabel="x",ylabel="y",
contour_levels=10,contour=base,explicit(sin(x*y),x,-2,2,y,-2,2));
vector valued functions
load(eigen);
load(vect);
r(t):=[sin(t), cos(t), t];
define(v(t), diff(r(t),t) );
define(speed(t), sqrt(v(t).v(t)) );
define(T(t), unitvector(v(t)) );
define(a(t), diff(v(t),t) );
define(Tprime(t), diff(T(t),t) );
define(N(t), unitvector(Tprime(t)) );
define(aT(t), diff(speed(t),t));
define(aN(t), sqrt(a(t).a(t) - aT(t)^2) );
define(kurv(t), aN(t) / (v(t).v(t)) );
define(R(t), 1/kurv(t) );
define(B(t), express(T(t)~N(t)) );
float(v(1));
float(a(1));
float(aT(1)*T(1) + aN(1)*N(1));
multivariable optimization
load(vect)$
load(draw)$
scalefactors([x,y])$
realonly:true$
f(x,y):=(x-2)^2+(y-1)^2+(.5*x^2+y^2-5)^2;
define(g(x,y),ev(express(grad(f(x,y))),diff));
define(H(x,y), subst([x=x,y=y], hessian(f(x,y),[x,y])));
solns:solve(g(x,y),[x,y]);
for soln in solns do (
  print(float(soln)," z=",float(ev(f(x,y),soln))), 
  print("H=", float(ev(H(x,y),soln))," D=",float(ev(determinant(H(x,y)),soln))) );
draw3d(enhanced3d=true,surface_hide=true,xu_grid=50,yv_grid=50,xlabel="x",ylabel="y",
contour_levels=100,contour=base,explicit(f(x,y),x,-2.5,4,y,-1,2));
Lagrange multipliers
f(x,y):=x^2+2*y^2;
g(x,y):=y-x^2+4;
solns:solve( [ diff(f(x,y),x)-L*diff(g(x,y),x), diff(f(x,y),y)-L*diff(g(x,y),y), 
               g(x,y)], [x,y,L])$
for soln in solns do (
  print(soln," f=",float(ev(f(x,y),soln))) );
Milk-maid problem
load(draw)$
load(mnewton)$
f(x,y):=sqrt((x+1)^2+y^2)+sqrt((x-1)^2+y^2);
g(x,y):=(x^2+3*y-6)*(y-2)-3*x;
x0:-2; x1:2; y0:-2; y1:4;
draw2d(  grid = true, color = black,
    point_size = 5,point_type = filled_square, points([ [-1,0], [1,0] ]),
    color = blue,line_width = 4, implicit(g(x,y) = 0,x,x0,x1,y,y0,y1),
    line_width=2,
    color = red,         implicit(f(x,y)=2.03,x,x0,x1,y,y0,y1),
    color = orange,      implicit(f(x,y)=2.1,x,x0,x1,y,y0,y1),
    color = purple,      implicit(f(x,y)=2.5,x,x0,x1,y,y0,y1),
    color = forest_green,implicit(f(x,y)=3,x,x0,x1,y,y0,y1),
    color = brown,       implicit(f(x,y)=3.5,x,x0,x1,y,y0,y1),
    color = pink,        implicit(f(x,y)=4,x,x0,x1,y,y0,y1) 
)$
soln:mnewton([ g(x,y), diff(f(x,y),x)-L*diff(g(x,y),x), diff(f(x,y),y)-L*diff(g(x,y),y) ], [x,y,L], [1,.5,0]);
ev(f(x,y),soln);

Sage


Markdown / Latex

fraction$\frac{ x+2 } { x^2+1 }$
subscript and superscript$x_a^{12}$
square root$\sqrt{x}$
integral symbol$\int_0^{2x} f(t) dt$
derivatives$\frac{dy}{dx}$
$\frac{\partial y}{\partial x}$

Wolfram Alpha


GeoGebra