next up previous
Next: Newton-Raphson Method for Solving Up: No Title Previous: No Title

Derivatives, Functions, Integrals, Taylor Series, Limits

Maple session Comments



> diff(cos(x),x); 
             - sin(x)
_______________________________
> diff(cos(x),x,x);
             - cos(x)
_______________________________
> diff(log(sin(x)),x);
              cos(x)
              ------
              sin(x)





The command diff does differentiation. Repeating the variable gives a second derivative. Maple knows a wide variety of standard functions. The names are generally self-evident.





> r := sqrt(x^2+y^2+z^2); 
             2    2    2 1/2
      r := (x  + y  + z )
_________________________________
> V := proc(x,y,z) 1/r end;
V := proc(x,y,z) 1/r end
_________________________________
> V := (x,y,z) -> 1/r:
_________________________________
> diff(V(x,y,z),x);
                 x
       - -----------------
           2    2    2 3/2
         (x  + y  + z )





You can define your own functions. The first command assigns the expression $\sqrt{x^2+y^2+z^2}$ to the name r. The second command defines a function V(x,y,z) in terms of r. Notice that it is necessary to specify the dependent variables by including them as arguments to the Maple proc() function. The actual statement(s) that define the function are placed between the proc() and end. The reason for the end flag is that function procedures can run on to several lines, and it is necessary to indicate which is the last line. The third command shows the alternative arrow notation that works for simple functions. Notice that the partial derivative is taken in the fourth command.





> diff(V(x,y,z),x,y);
                x y
       3 -----------------
           2    2    2 5/2
         (x  + y  + z )





This is the way to get $\partial^2 V/\partial x \partial y$.


Maple session Comments



> int(x^3*cos(x),x); 
  3             2
 x  sin(x) + 3 x  cos(x) 

- 6 cos(x) - 6 x sin(x)





Indefinite integral $\int x^3 \cos x dx$





> int(sin(t)/t,t=0..x); 
              Si(x)





Definite integral $\mathop{\rm Si}\nolimits(x) = \int_0^x \sin t dt/t$. This integral can't be reduced to more standard functions, so it is just called the sine integral and given the name $\mathop{\rm Si}\nolimits(x)$.





> taylor(",x); 
            3          5      6
  x - 1/18 x  + 1/600 x  + O(x )





The Taylor series expansion of $\mathop{\rm Si}\nolimits(x)$ at x = 0.





> Order := 10;
           Order := 10
_______________________________
> taylor("",x);
             3          5 
   x - 1/18 x  + 1/600 x  -

           7              9      10
  1/35280 x  + 1/3265920 x  + O(x  )





You can get more terms in the Taylor series by changing the preassigned value of Order.





> taylor(sin(x),x=Pi);
                                   3  
          - (x - Pi) + 1/6 (x - Pi)  - 
                   5             6
     1/120 (x - Pi)  + O((x - Pi) )





Use x=a to get the Taylor series expansion about x=a.





> f := proc(x,h) 
   (sin(x+h) - sin(x))/h end;
f := proc(x,h) (sin(x+h)-sin(x))/h end

__________________________________
> limit(f(x,h),h=0);
                 cos(x)





This is how to find a limiting value. In this case the expression defines the derivative of $\sin x$ at x.


Maple session Comments



> evalf(erf(1));
              .8427007929
___________________________
> evalf(erf(2));
              .9953222650
___________________________
> limit(erf(x),x=infinity);
                   1





The error function, known to Maple, is defined as

\begin{displaymath}
\mathop{\rm erf}\nolimits(x) = \frac{2}{\sqrt{\pi}}\int_0^x \exp(-t^2) dt
 \end{displaymath}





 

next up previous
Next: Newton-Raphson Method for Solving Up: No Title Previous: No Title
Craig McNeile
4/20/1998