1.
(a)
[X, Y] = meshgrid(-1:0.1:1, -1:0.1:1); contour(X, Y, 3*Y + Y.^3 - X.^3, 'k')
[X, Y] = meshgrid(-10:0.1:10, -10:0.1:10); contour(X, Y, 3*Y +
Y.^3 - X.^3, 'k')
Here
is a plot with more level curves.
[X, Y] =
meshgrid(-10:0.1:10, -10:0.1:10); contour(X, Y, 3*Y + Y.^3 - X.^3, 30, 'k')
(b)
Now we plot the level curve through 5.
[X, Y] =
meshgrid(-5:0.1:5, -5:0.1:5); contour(X, Y, 3.*Y + Y.^3 - X.^3, [5 5],
'k')
(c)
We
note that f(1, 1) = 0, so the
appropriate command to plot the level curve of f through the point (1, 1) is
[X, Y] =
meshgrid(0:0.1:2, 0:0.1:2); contour(X, Y, Y.*log(X) + X.*log(Y), [0 0], 'k')
Warning: Log of zero.
2.
We
find the derivatives of the given functions:
(a)
diff(6*x^3 - 5*x^2 + 2*x - 3, x)
18*x^2-10*x+2
(b)
2/(x^2+1)-2*(2*x-1)/(x^2+1)^2*x
-2*(x^2-1-x)/(x^2+1)^2
(c)
6*cos(3*x^2+2)*x
(d)
1/(-2-x^2-3*x)^(1/2)
(e)
2/(1+x^4)^(1/2)*x^3
(f)
x^r*r/x
(g)
2*x/(1+(x^2+1)^2)
3.
We
compute the following integrals.
(a)
1
(b)
-1/2*cos(x^2)
To
check the indefinite integral, we just differentiate.
x*sin(x^2)
(c)
int(sin(3*x)*sqrt(1 - cos(3*x)), x)
2/9*(1-cos(3*x))^(3/2)
sin(3*x)*(1-cos(3*x))^(1/2)
(d)
2/7*(x+4)^(7/2)-16/5*(x+4)^(5/2)+32/3*(x+4)^(3/2)
(x+4)^(5/2)-8*(x+4)^(3/2)+16*(x+4)^(1/2)
x^2*(x+4)^(1/2)
(e)
pi^(1/2)
4.
(a)
syms x; int(exp(sin(x)), x, 0, pi)
Warning: Explicit integral could not be found.
> In C:\MATLABR12\toolbox\symbolic\@sym\int.m at line 58
ans =
int(exp(sin(x)),x = 0 .. pi)
format long; quadl('exp(sin(x))', 0, pi)
6.20875803571375
(b)
1.11144798484585
(c)
MATLAB
integrated this one exactly in 4(e) above; let's integrate it numerically and
compare answers. Unfortunately, the
range is infinite, so to use quadl we have to approximate the interval. Note that
6.305116760146989e-016
which
is close to the standard floating point accuracy, so:
format long; quadl('exp(-x.^2)', -35, 35)
1.77245385102263
1.77245385090552
The
answers agree up to 10 digits.
5.
(a)
1
(b)
limit((1 + cos(x))/(x + pi), x, -pi)
0
(c)
0
(d)
limit(1/(x - 1), x, 1, 'left')
-inf
(e)
limit(sin(1/x), x, 0, 'right')
-1 .. 1
This
means that every real number in the interval between -1
and +1 is a "limit point" of sin(1/x) as x tends to
zero. You can see why if you plot sin(1/x) on the interval (0, 1].
6.
(a)
1/3*(n+1)^3-1/2*(n+1)^2+1/6*n+1/6
1/3*n^3+1/2*n^2+1/6*n
(b)
r^(n+1)/(r-1)-1/(r-1)
(n + 1)
r 1
-------- - -----
r - 1 r - 1
(c)
symsum(x^k/factorial(k), k, 0, Inf)
Function 'fix' not defined for variables of class 'sym'.
Error in ==> C:\MATLABR12\toolbox\matlab\specfun\factorial.m
On line 14 ==> if (length(n)~=1) | (fix(n) ~= n) | (n < 0)
Here
are two ways around this difficulty.
The second method will not work with the Student Version.
symsum(x^k/gamma(k + 1), k, 0, Inf)
exp(x)
symsum(x^k/maple('factorial', k), k, 0, Inf)
exp(x)
(d)
symsum(1/(z - k)^2, k, -Inf, Inf)
pi^2+pi^2*cot(pi*z)^2
7.
(a)
1+x+1/2*x^2+1/6*x^3+1/24*x^4+1/120*x^5+1/720*x^6
(b)
x-1/6*x^3
x-1/6*x^3+1/120*x^5
(c)
sin(2)+cos(2)*(x-2)-1/2*sin(2)*(x-2)^2-1/6*cos(2)*(x-2)^3+1/24*sin(2)*(x-2)^4+1/120*cos(2)*(x-2)^5
(d)
x+1/3*x^3+2/15*x^5
(e)
x-1-1/2*(x-1)^2+1/3*(x-1)^3-1/4*(x-1)^4
(f)
2/pi^(1/2)*x-2/3/pi^(1/2)*x^3+1/5/pi^(1/2)*x^5-1/21/pi^(1/2)*x^7
8.
(a)
syms x y; ezsurf(sin(x)*sin(y), [-3*pi 3*pi –3*pi 3*pi])
(b)
syms x y; ezsurf((x^2 + y^2)*cos(x^2 + y^2), [-1 1 -1 1])
9.
You can't do animations in an
M-Book. But from the Command Window,
you can type:
T =
0:0.01:1;
for j
= 0:16
fill(4*cos(j*pi/8)+(1/2)*cos(2*pi*T), ...
4*sin(j*pi/8)+(1/2)*sin(2*pi*T), 'r'); axis
equal; axis([-5 5 –5 5]);
M(j+1) = getframe;
end
movie(M)