Note: This exam was originally written when we were using Mathematica in the course. All the Mathematica code has been translated into MATLAB.
>> syms t
>> r = [(2*t+1)/(t-1), t^2/(t-1), t+2];
>> v=diff(r); a=diff(v); g=diff(a); h=cross(v,a);
>> simplify(h*transpose(g))
ans =
0
>> subs(v, t, 1/2)
ans =
-12 -3 1
>> subs(h, t, 1/2)
ans =
16 -48 48
>> subs(cross(h,v), t, 1/2)
ans =
96 -592 -624
>> syms x y
>> f=x^3+y^3-x*y^2+2*x^2*y-x^2-y^2; pretty(f)
3 3 2 2 2 2
x + y - x y + 2 x y - x - y
>> fx=diff(f,x); fy=diff(f,y); fxx=diff(fx,x); fyy=diff(fy,y);
>> fxy=diff(fx,y); disc=fxx*fyy-fxy^2;
>> [xcr,ycr]=solve(fx,fy);
>> discf=inline(vectorize(disc)); fxxf=inline(vectorize(fxx));
>> double([xcr,ycr,discf(xcr,ycr),fxxf(xcr,ycr)])
ans =
0 0 4.0000 -2.0000
-0.2222 0.4444 -4.8889 -1.5556
0.3022 0.7912 6.2413 2.9780
0.4564 0.1743 -4.8620 1.4358
>> ff=inline(vectorize(f));
>> [xx,yy]=meshgrid(-.5:.01:.5, -.2:.01:.8); zz=ff(xx,yy);
>> contour(xx,yy,zz,-2.5:.05:2.5)
>> syms x y z
>> addpath nit
>> numint3(z,z,sqrt(x^2+y^2),2,y,-sqrt(4-x^2),sqrt(4-x^2),x,-2,2)
ans =
12.5657
>> newnumint2(sin(12*x-x^3),x,0,sqrt(y/3),y,0,12)
ans =
1.9577
>> newnumint2(x^2,y,0,3*sqrt(1-x^2/4),x,0,2)
ans =
4.7128
>> syms x y z
>> curl=inline(['[diff(F3,y)-diff(F2,z),', ...
'diff(F1,z)-diff(F3,x), diff(F2,x)-diff(F1,y)]'], 'F1','F2','F3','x','y','z')
curl =
Inline function:
curl(F1,F2,F3,x,y,z) = [diff(F3,y)-diff(F2,z),diff(F1,z)-diff(F3,x),
diff(F2,x)-diff(F1,y)]
>> grad = inline('[diff(f,x),diff(f,y),diff(f,z)]', 'f', 'x','y','z')
grad =
Inline function:
grad(f,x,y,z) = [diff(f,x),diff(f,y),diff(f,z)]
>> curl(x,y,z,x,y,z)
ans =
[ 0, 0, 0]
>> term1=curl('f(x,y,z)*F1(x,y,z)','f(x,y,z)*F2(x,y,z)','f(x,y,z)*F3(x,y,z)',...
x,y,z)
term1 =
[
diff(f(x,y,z),y)*F3(x,y,z)+f(x,y,z)*diff(F3(x,y,z),y)-diff(f(x,y,z),z)*F2(x,y,z)
-f(x,y,z)*diff(F2(x,y,z),z),
diff(f(x,y,z),z)*F1(x,y,z)+f(x,y,z)*diff(F1(x,y,z),z)-diff(f(x,y,z),x)*F3(x,y,z)
-f(x,y,z)*diff(F3(x,y,z),x),
diff(f(x,y,z),x)*F2(x,y,z)+f(x,y,z)*diff(F2(x,y,z),x)-diff(f(x,y,z),y)*F1(x,y,z)
-f(x,y,z)*diff(F1(x,y,z),y)]
>> term2='f(x,y,z)'*curl('F1(x,y,z)','F2(x,y,z)','F3(x,y,z)',x,y,z)
term2 =
[ f(x,y,z)*(diff(F3(x,y,z),y)-diff(F2(x,y,z),z)),
f(x,y,z)*(diff(F1(x,y,z),z)-diff(F3(x,y,z),x)),
f(x,y,z)*(diff(F2(x,y,z),x)-diff(F1(x,y,z),y))]
>> term3=cross(sym(grad('f(x,y,z)',x,y,z)), ...
sym('[F1(x,y,z),F2(x,y,z),F3(x,y,z)]'))
term3 =
[ diff(f(x,y,z),y)*F3(x,y,z)-diff(f(x,y,z),z)*F2(x,y,z),
diff(f(x,y,z),z)*F1(x,y,z)-diff(f(x,y,z),x)*F3(x,y,z),
diff(f(x,y,z),x)*F2(x,y,z)-diff(f(x,y,z),y)*F1(x,y,z)]
>> simplify(term1-term2-term3)
ans =
[ 0, 0, 0]