2 (4 points).

a) Compute the gradient vector field of the function f(x,y,z) = x ln(y) - z
ln(x).

Solution. The three components are:

In[5]:=

  f[x_,y_,z_] := x Log[y] - z Log[x]

In[6]:=

  { D[x Log[y] - z Log[x],x],
    D[x Log[y] - z Log[x],y],
     D[x Log[y] - z Log[x],z]}

Out[6]=

     z            x
  {-(-) + Log[y], -, -Log[x]}
     x            y

The set on which this is defined is the set of all {x,y,z} such that x
and y are positive. This is an open set (the set get arbitrarily close to where x = 0 or
y = 0, but does not include these boundary points. It is also connected,

c) Calculate the integral of grad f dotted with dx along the straight line
from (1,1,1) to (2,1,1).

Solution. The easy way to do this is to know that the integral equals f(2,1,1)
- f(1,1,1):

In[7]:=

  f[2,1,1] - f[1,1,1]

Out[7]=

  -Log[2]

Alternatively, we could set up a line integral. The straight line can be
parametrized as

In[8]:=

  Clear[x,y,z]

In[9]:=

  x[t_] := 1 + t
  y[t_] := 1
  z[t_] := 1

The time t will go from 0 to 1. We take the dot product of F with the
velocity:

In[10]:=

  { D[x Log[y] - z Log[x],x],
    D[x Log[y] - z Log[x],y],
     D[x Log[y] - z Log[x],z]}.{x'[t],y'[t],z'[t]} \
     /. {x -> 1+t,y -> 1, z -> 1} 
         

Out[10]=

      1
  -(-----)
    1 + t

In[11]:=

  Integrate[%, {t,0,1}]

Out[11]=

  -Log[2]

What a coincidence, the same number!




Up to Test 3 solutions