Assignment 2
Assignment 2
Math 205
Assignment 2
Exercise 2.1
function y = liwayfunc(x)
y = x.^2 .* exp(-x.^2)
>> x=-5:.1:5
x=
Columns 1 through 9:
4.9000 5.0000
>> y = liwayfunc(x)
y=
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0002 0.0004 0.0006
0.0011 0.0019 0.0031 0.0050 0.0078 0.0121 0.0182 0.0267 0.0383 0.0536
0.0733 0.0977 0.1269 0.1606 0.1979 0.2371 0.2761 0.3118 0.3412 0.3608
0.3679 0.3603 0.3375 0.3002 0.2512 0.1947 0.1363 0.0823 0.0384 0.0099
Columns 51 through 60:
0.3679 0.3608 0.3412 0.3118 0.2761 0.2371 0.1979 0.1606 0.1269 0.0977
0.0733 0.0536 0.0383 0.0267 0.0182 0.0121 0.0078 0.0050 0.0031 0.0019
0.0011 0.0006 0.0004 0.0002 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Column 101:
0.0000
>> plot(x,y)
Exercise 2.2
% mygraph
% plots the graphs of sin x, sin 2x, sin 3x, sin 4x, sin 5x, and sin 6x
x = 0:.1:2*pi
% calculate powers
z = sin(x)
z2 = (sin(x)).^2
z3 = (sin(x)).^3
z4 = (sin(x)).^4
z5 = (sin(x)).^5
z6 = (sin(x)).^6
>> x= 0:.1:2*pi
x=
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
1.1000 1.2000 1.3000 1.4000
1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000
2.6000 2.7000 2.8000 2.9000
3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000
4.1000 4.2000 4.3000 4.4000
4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000
5.6000 5.7000 5.8000 5.9000
Columns 61 through 63:
>> mygraph
z=
Columns 1 through 9:
z2 =
Columns 1 through 9:
z3 =
Columns 1 through 9:
z4 =
Columns 1 through 9:
z5 =
Columns 1 through 9:
z6 =
Columns 1 through 9:
% plots the graphs of sin x, sin 2x, sin 3x, sin 4x, sin 5x, and sin 6x
x = 0:.1:2*pi
% calculate powers
z = sin(x)
z2 = sin(2.*x)
z3 = sin(3.*x)
z4 = sin(4.*x)
z5 = sin(5.*x)
z6 = sin(6.*x)
x = 0:.1:2*pi
x=
Columns 1 through 8:
x=
Columns 1 through 8:
z=
Columns 1 through 9:
0 0.0998 0.1987 0.2955 0.3894 0.4794 0.5646 0.6442 0.7174
z2 =
Columns 1 through 9:
0 0.1987 0.3894 0.5646 0.7174 0.8415 0.9320 0.9854 0.9996
z3 =
Columns 1 through 9:
z4 =
Columns 1 through 9:
Columns 1 through 9:
Columns 1 through 9: