Computer Tools

Matlab and Maple are available with limited online access for WSU Math course students from the MyMath website; after login, just follow the "Software" link. More information about Matlab can be found using the MyMath Matlab help command. Math students at Washington State University may also use Matlab in one of the Math Department Labs . Some sample Matlab commands are given below.

Here is a Matlab example command for plotting a simple function x^3-4x^2+4x-1 :
ezplot( 'x^3 - 4*x^2 + 4*x - 1', [-1 3] )

Some Matlab example commands for nested polynomial evaluation of P(x) = 2x^4-x^3-4x^2+4x-1 at x0 = 3:
c = [-1 4 -4 -1 2]; d = 4; x0 = 3;
P = c(d+1); for i = d:-1:1, P = c(i) + x0*P; end, disp(P)

Some Matlab example commands for computing a table of values for the function f(x) = (x^4+x-18)/(x^2-4) near x=2:
x = [1.9995 : .0002 : 2.0005];
f = (x.^4 + x - 18)./(x.^2 - 4);
disp([x' f'])

Some Matlab example commands for computing an approximate derivative for x^ln(x) at x = 2:
h = 10.^(-[0:2:10]');
f = @(x)x.^log(x);
format long g
disp([2+h (f(2+h)-f(2))./h])

Some Matlab example commands for (approximately) finding a local maximum of f(x)=x^3-4x^2+4x-1 and the point where the maximum occurs:
x = [-1:.01:2]; f = x.^3 - 4*x.^2 + 4*x - 1;
[ M, j] = max(f); disp([M x(j)])

Some Matlab example commands for finding an approximation to the definite integral of f(x) for x from 1 to 6 using the midpoint rule with n = 32 points:
n = 32; a = 1; b = 6; h = (b-a)/n;
f = @(x)x.^3 - 4*x.^2 + 4*x - 1;
disp( h*sum(f(a+h*[1:2:2*n-1]/2)) ) % Midpoint Rule

Some Matlab example commands for finding an approximation to the definite integral of f(x) for x from 1 to 6 using the trapezoidal rule and Simpson's rule with n = 32 points:
n = 32; a = 1; b = 6; h = (b-a)/n;
f = @(x)x.^3 - 4*x.^2 + 4*x - 1;
T = h*( f(a) + 2*sum(f(a+h*[1:n-1])) + f(b) )/2;
disp(T) % Trapezoidal Rule
S = h*(f(a)+4*sum(f(a+h*[1:2:n-1]))+2*sum(f(a+h*[2:2:n-2]))+f(b))/3;
disp(S) % Simpson's Rule