0% found this document useful (0 votes)
20 views4 pages

Lab 3

Uploaded by

j6265678
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Lab 3

Uploaded by

j6265678
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Example

/* to find flow of the function f(x,y) in u directions whenever x=x(u,v),


y=y(u,v)*/
f:x^3+y^3-3*x*y;
fx:diff(f,x);
fy:diff(f,y);
x:u^2-v^2+2;
y:sin(u*v)-u+v;
xu:diff(x,u);
xv:diff(x,v);
yu:diff(y,u);
yv:diff(y,v);
fu:fx*xu+fy*yu;
xval:ev(x,u=1,v=0);
yval:ev(y,u=1,v=0);
flow:ev(fu,u=1,v=0,x=xval,y=yval);
print("The flow of", f, "in the u direction at (u,v)=(1,0) is equal to", flow,
"units")$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Example

/* to find the value of (1/2)ux+(1/3)uy+(1/4)uz given that


u=f(2x-3y,3y-4z,4z-2x)*/
u:f(p,q,r);
p:2*x-3*y;
q:3*y-4*z;
r:4*z-2*x;
px:diff(p,x);
py:diff(p,y);
pz:diff(p,z);
qx:diff(q,x);
qy:diff(q,y);
qz:diff(q,z);
rx:diff(r,x);
ry:diff(r,y);
rz:diff(r,z);
ux:fp*px+fq*qx+fr*rx;
uy:fp*py+fq*qy+fr*ry;
uz:fp*pz+fq*qz+fr*rz;
val:(1/2)*ux+(1/3)*uy+(1/4)*uz;
ans:ratsimp(val);
print("The value of (1/2)ux+(1/3)uy+(1/4)uz at any point is equal to ", ans)$
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Example

/*Find the total differential of x^2*y with respect to x at (x,y)=(1,1), when x


and y are connected by the relation x^2+x*y+y^2=1*/
z:x^2*y;
zx:diff(z,x);
zy:diff(z,y);
f:x^2+x*y+y^2-1;
fx:diff(f,x);
fy:diff(f,y);
y1:(-1)*(fx/fy);
dz:zx+zy*y1;
ans:ev(dz, x=1, y=1);
print("The total differential of x^2*y with respect to x at (x,y)=(1,1) is",
ans)$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Example

/* Problem: If x increases at the rate of 3 cm/sec at the instant when x = 3 cm


and y = 1 cm , at what rate must be changing in order that the function 2 xy-3
x^2 y
shall be neither increasing nor decreasing*/

f:2*x*y-3*x^2*y;
fx:diff(f,x);
fy:diff(f,y);
/* given xt=dx/dt=3 and ft=df/dt=0, at x=3 and y=1*/
flowrate:ft=fx*xt+fy*yt;
val:solve(flowrate,yt);
ans:ev(val,x=3,y=1,xt=3,ft=0);
print("The value of y shall decrease at a rate of ", abs(ans), "per second")$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Jacobian

/* to find J(u,v) for u=x^2+y^2 and v=2xy */


u:x^2+y^2;
v:2*x*y;
ux:diff(u,x);
uy:diff(u,y);
vx:diff(v,x);
vy:diff(v,y);
J:matrix([ux,uy],[vx,vy]);
JA:determinant(J);
print("The jacobian of",u,"and",v,"is equal to",JA)$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Jcobian of explicit function

/* to find J(u,v,w) for u=x+y+z, uv=y+z and uvw=z*/


f1:u-x-y-z;
f2:u*v-y-z;
f3:u*v*w-z;
f1x:diff(f1,x);
f1y:diff(f1,y);
f1z:diff(f1,z);
f2x:diff(f2,x);
f2y:diff(f2,y);
f2z:diff(f2,z);
f3x:diff(f3,x);
f3y:diff(f3,y);
f3z:diff(f3,z);
f1u:diff(f1,u);
f1v:diff(f1,v);
f1w:diff(f1,w);
f2u:diff(f2,u);
f2v:diff(f2,v);
f2w:diff(f2,w);
f3u:diff(f3,u);
f3v:diff(f3,v);
f3w:diff(f3,w);
J1:matrix([f1x,f1y,f1z], [f2x,f2y,f2z],[f3x,f3y,f3z]);
J2:matrix([f1u,f1v,f1w],[f2u,f2v,f2w],[f3u,f3v,f3w]);
JA1:determinant(J1);
JA2:determinant(J2);
JA:(-1)^(3)*(JA1/JA2);
print("The jacobian of",f1,"=0",f2,"=0", "and",f3,"=0","is equal to",JA)$
print("Therefore", if(JA=0) then "the functions u,v,w are dependent" else "the
functions u,v,w are independent")$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

/* to find J(x,y,x) for u=x+y+z, uv=y+z and uvw=z*/


f1:u-x-y-z;
f2:u*v-y-z;
f3:u*v*w-z;

f1u:diff(f1,u);
f1v:diff(f1,v);
f1w:diff(f1,w);
f2u:diff(f2,u);
f2v:diff(f2,v);
f2w:diff(f2,w);
f3u:diff(f3,u);
f3v:diff(f3,v);
f3w:diff(f3,w);

f1x:diff(f1,x);
f1y:diff(f1,y);
f1z:diff(f1,z);
f2x:diff(f2,x);
f2y:diff(f2,y);
f2z:diff(f2,z);
f3x:diff(f3,x);
f3y:diff(f3,y);
f3z:diff(f3,z);

J1:matrix([f1u,f1v,f1w],[f2u,f2v,f2w],[f3u,f3v,f3w]);
J2:matrix([f1x,f1y,f1z], [f2x,f2y,f2z],[f3x,f3y,f3z]);

JA1:determinant(J1);
JA2:determinant(J2);
JA:(-1)^(3)*(JA1/JA1);
print("The jacobian of",f1,"=0",f2,"=0", "and",f3,"=0","is equal to",JA)$
print("Therefore", if(JA=0) then "the functions u,v,w are dependent" else "the
functions u,v,w are independent")$

%%%%%%%%%%%%% OR %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

Aliternate method

/* to find J(u,v,w) for u=x+y+z, uv=y+z and uvw=z*/


f1:u-x-y-z;
f2:u*v-y-z;
f3:u*v*w-z;
J1:jacobian([f1,f2,f3],[u,v,w]);
J2:jacobian([f1,f2,f3],[x,y,z]);
JA1:determinant(J1);
JA2:determinant(J2);
JA:(-1)^(3)*(JA1/JA2);
print("The jacobian of",f1,"=0",f2,"=0", "and",f3,"=0","is equal to",JA)$
print("Therefore", if(JA=0) then "the functions u,v,w are dependent" else "the
functions u,v,w are independent")$

You might also like