CHAPTER 6

image

Series, Continuity, Derivatives, Integrals and Differential Equations

6-1. Predefined Symbolic Functions

MATLAB provides a group of predefined special symbolic functions, whose syntax is presented in the following table:

cosint(x)

Cosine integral, image

sinint(x)

Sine integral, image

hypergeom(n,d,z)

Generalized hypergeometric function.

lambertw(x)

Solves the equation λ (x)eλ(x) = x.

Zeta(x)

Riemann zeta function, defined as image

Zeta (n,x)

nth derivative of zeta (x).

As a first example, we find the sum of the series image, whose value will be Z(4).

>> zeta(4)
ans =

    1.0823

Then to solve the integral image we use the sine integral function:

>> sinint(2)
ans =
    1.6054

6-2. Functions for Mathematical Analysis: Limits, Continuity and Series

MATLAB’s symbolic mathematics module enables you to explore mathematical analysis with ease. You can calculate limits, obtain derivatives, find the sum of series, expand functions as Taylor series, calculate integrals, and work with equations.

When calculating limits and working with numerical series, the same functions are used to calculate limits of sequences, limits of functions, and limits of sequences of functions, and of course, to analyze the continuity of functions and convergence of numerical series and power series. The analysis for single and multiple variables is similar. This group of functions includes the following.

limit(sequence,inf)

Calculates the limit of the sequence, indicated by its general term, as n tends to infinity

limit(function,x,a)

Calculates the limit of the function of the variable x, indicated by its analytical expression, as the variable x tends towards the value a.

limit(function,a)

Calculates the limit of the function of the variable x, indicated by its analytical expression, as the variable x tends toward the value a.

limit(function,x,a,'right')

Calculates the limit of the function of the variable x, indicated by its analytical expression, as the variable x tends toward the value from the right.

limit(function,x,a,'left')

Calculates the limit of the function of the variable x, indicated by its analytical expression, as the variable x tends toward the value from the left.

symsum(S,v,a,b)

Sums the series S with respect to the variable v varying from a to b.

symsum(S,v)

Sums the series S with respect to the variable v varying from 0 to v-1.

r = symsum(S)

Sums the series S with respect to its symbolic variable k (as determined by findsym) from 0 up to k-1.

symsum(S,a,b)

Sums the series S with respect to its symbolic variable k (determined by findsym), varying between a and b.

As a first example we calculate the limits of the following sequences:

image

We have:

>> syms n
>> limit(((2*n-3)/(3*n-7))^4,inf)
ans =

16/81
>> limit((3*n^3+7*n^2+1)/(4*n^3-8*n+5),n,inf)
ans =

3/4
>> limit(((n+1)/2) * ((n^4+1)/n^5),inf)
ans =

1/2
>> limit(((n+1)/n^2)^(1/n),inf)
ans =

1

Next we calculate the limits of the following functions:

image

We have:

>> syms x a
>> limit((x-1)/(x^(1/2)-1),x,1)
ans =

2
 >> limit((x-(x+2)^(1/2))/((4*x+1)^(1/2)-3),2)
ans =

9/8
>> limit((1+x)^(1/x))
ans =

exp (1)
>> limit(sin(a*x)^2/x^2,x,0)
ans =

a^2

In the following example, we calculate the limit function of the sequence of functions defined by gn(x) = (x2+nx) /n with x∈R.

>> limit((x^2+n*x)/n,n,inf)
ans =

x

We have obtained the limit function, which is the diagonal of the first and third quadrants. We illustrate this graphically (Figure 6-1) as follows:

>> fplot('[(x^2+x),(x^2+2*x)/2,(x^2+3*x)/3,(x^2+4*x)/4,
(x^2+5*x)/5,(x^2+5*x)/5,(x^2+6*x)/6,(x^2+7*x)/7,(x^2+8*x)/8,
(x^2+9*x)/9]',[-2,2,-2,2])

The following example checks the continuity in R-{0} of the function f(x) = sin(x) /x . This will verify that image

>> syms x a
>> limit(sin(x)/x, x, a)
ans =

sin(a)/a

We then confirm that the function image is not continuous at the point x = 0, because the lateral limits do not match (one is zero and the other infinite).

>> syms x
>> limit((exp(1/x)),x,0,'right')
ans =

inf
>> limit((exp(1/x)),x,0, 'left')
ans =

0

In the following example we test whether the numerical series image is convergent by applying the ratio test image and, if so, we calculate its sum.

>> syms n
>> f = n/2^n
f =

n/(2^n)
>> limit(subs(f,n,n+1)/f, n, inf)
ans =

1/2

We can see that the limit is less than 1, so we conclude that the series converges. We calculate the sum in the following way:

>> symsum(f,n,1,inf)
ans =

2

6-3. Derivatives, Integrals and Differential Equations

MATLAB provides the following functions for mathematical analysis, a group that includes commands relating to derivatives, integrals, and differential equations. We will begin with the functions related to differentiation.

diff('f','x')

Returns the derivative of the function f with respect to x.

syms x, diff(f,x)

Returns the derivative of the function f with respect to x.

diff('f', 'x', n)

Returns the nth derivative of f with respect to x.

syms x, diff(f,x,n)

Returns the nth derivative of f with respect to x.

r = taylor(f,n,v)

Returns the MacLaurin series up to order n-1 of the

function f in the variable v.

r = taylor(f)

Returns the MacLaurin series up to order 5 of the function f in the default variable.

r = taylor(f,n,v,a)

Returns the Taylor series up to order n-1 of the function f in the variable v in a neighbourhood of the point a.

R = jacobian(w,v)

Returns the Jacobian matrix of w with respect to v.

The following are the integration-related functions:

syms x, int(f(x),x) or int('f(x)', 'x')

Computes the indefinite integral image.

int(int('f(x,y)', 'x'); 'y')

Calculates the double integral image

syms x y, int(int(f(x,y),x),y)

Calculates the double integral image.

int(int(int(... int('f(x,y...z)', 'x'); 'y');..., 'z')

image

syms x y z,

int(int(int(... int(f(x, y,...,z), x), y)..., z)

image

syms x a b, int(f(x),x,a,b)

Calculates the definite integral image.

int('f(x)', 'x', 'a', 'b')

Calculates the definite integral image.

int(int('f(x,y)', 'x', 'a', 'b'); 'y', 'c', 'd')

Computes the integral image

syms x y a b c d,

int (int (f(x,y), x, a, b), y, c, d)

Calculates image.

int(int(int(...int('f(x,y,...,z)', 'x', 'a', 'b'); 'y', ' it, ' from),...), 'z', 'e', 'f')

image

Syms x y z a b c d e f,

int (int (int (... int(f(x,y,...,z), x, a, b), y, c, d),...), z, e, f)

image

The following table summarizes the functions related to differential equations:

dsolve('e', 'v')

Solves the differential equation where v is the independent variable (if you don't specify 'v', the independent variable is assumed by default to be x). It returns only explicit solutions.

dsolve('e', 'c', 'v')

Solves the differential equation subject to the specified initial condition c.

dsolve('e','c1','c2',...,'cn','v')

Solves the differential equation e subject to the specified initial conditions ci.

dsolve('e','c1,c2,...,cn','v')

Solves the differential equation subject to the specified initial conditions.

dsolve('e1', 'e2',..., 'en',)

('c1', 'c2',..., 'cn', 'v')

Solves the given system of differential equations (explicitly) subject to the specified initial conditions.

dsolve('e1, e2,..., en',)

('c1, c2,..., cn', 'v')

Solves the given system of differential equations subject to the specified initial conditions.

As a first example, we calculate the derivative of the function log(sin(2x)).

>> pretty(diff('log(sin(2*x))','x'))
                           cos(2 x)
                       2  ---------
                           sin(2 x)

We can then find the fully simplified derivative:

>> pretty(simple(diff('log(sin(2*x))','x')))
                            2
                         --------
                         tan (2 x)

In the following example, we calculate the first four derivatives of the function f(x) = 1/x.

>> f='1/x';
 [diff(f),diff(f,2),diff(f,3),diff(f,4),diff(f,5)]
ans =

[-1/x ^ 2, 2/x ^ 3, - 6/x ^ 4, 24/x ^ 5, - 120/x ^ 6]

Next, given the function f(x,y) = sin(xy) +cos(xy2), we calculate the following:

image

>> syms x y
>> f = sin(x*y) + cos(x*y^2)
f =

sin(x*y) + cos(x*y^2)
>> diff(f,x)
ans =

cos(x*y) *-sin(x*y^2) * y ^ 2
>> diff(f,y)
ans =

cos(x*y) * x-2 * sin(x*y^2) * x * y
>> diff(diff(f,x),x)
ans =

-sin(x*y) * y ^ 2-cos(x*y^2) * y ^ 4
>> diff (diff(f,y), y)
ans =

-sin(x*y) * x ^ 2-4 * cos(x*y^2) * x ^ 2 * y ^ 2-2 * sin(x*y^2) * x
>> diff(diff(f,x),y)
ans =

-sin(x*y) * x * y + cos(x*y)-2 * cos(x*y^2) * x * y ^ 3-2 * sin(x*y^2) * y
>> diff(diff(f,y),x)
ans =

-sin(x*y) * x * y + cos(x*y)-2 * cos(x*y^2) * x * y ^ 3-2 * sin(x*y^2) * y
>> diff(diff(diff(diff(f,x),x),y,y))
ans =

sin(x*y) * y ^ 3 * x-3 * cos(x*y) * y ^ 2 + 2 * cos(x*y^2) * y ^ 7 * x + 6 * sin(x*y^2) * y ^ 5

Next we find the Taylor series up to order 10 of the function 1 /(2-x) in a neighborhood of the point x = 1

>> syms x
>> f=1/(2-x)
f =

1/(2-x)
>> pretty(taylor(f,11,x,1))
             2          3          4          5          6          7
  x + (x - 1)  + (x - 1)  + (x - 1)  + (x - 1)  + (x - 1)  + (x - 1)

                  8          9          10
         + (x - 1)  + (x - 1)  + (x - 1)

The following example computes the integral image.

>> int('1/(x^2-1)','x')
ans =

-atanh (x)

The following example finds the integral image where a and b are parameters.

>> syms x a b, pretty(simple(int(a*log(1+b*x),x)))
              a (log(1 + b x) - 1) (1 + b x)
              ------------------------------
                            b

The following example computes the double integral image where a is a parameter.

>> syms x a b, pretty(simple(int(int(a*log(1+b*x),x),b)))
a (-dilog(1 + b x) + log(1 + b x) + log(1 + b x) x b - 1 - 2 b x - log(b))

The following example computes the triple integral image.

>> syms x a b, pretty(simple(int(int(int(a*log(1+b*x),x),b),a)))
    2
1/2a(-dilog(1 + b x) + log(1 + b x) + log(1 + b x) x b - 1 - 2 b x - log(b))

Next we calculate image

>> syms x a b, pretty(simple(int(a * log(1+b*x), x, 0, 1)))
                        a log(1 + b)
                        ------------ - a + a log(1 + b)
                             b

The following example computes image

>> syms x a b, pretty(simple(int(int(a*log(1+b*x),x,0,1),b,2,3)))
              (- 2 + 8 log(2) - dilog(4) - 3 log(3) + dilog(3)) a

The following example solves the first-order, first-degree differential equation y'(t) = ay(t) with a = parameter.

>> pretty(dsolve('Dy = a*y'))
                            C1 exp (a t)

The family of solutions turns out to be y(t) = c1eat.

Next we solve the above differential equation with the initial condition y(0) = b.

>> pretty(dsolve('Dy = a*y', 'y(0) = b'))
                            b exp (a t)

Now we solve the second-degree, first-order differential equation y'2(s) + y2(s) = 1 with the initial condition y(0) = 0.

>> y = dsolve ('(Dy) ^ 2 + y ^ 2 = 1', 'y(0) = 0', 's')
y =

[-sin(s)]
[sin(s)]

Now we solve the differential equation of second order and first degree y"(t) = -a2y'(t) with the initial conditions y(0) = 1 and y'(p/a) = 0.

>> pretty(dsolve('D2y = - a ^ 2 * y', 'y(0) = 1, Dy(pi/a) = 0'))
                            cos(a t)

Therefore, the solution is the function y(t) = cos(at).

The following example solves the system: x'(t) = y(t), y'(t) = -x(t).

>> [x, y] = dsolve('Dx = y', 'Dy =-x')
x =

cos (t) * C1 + sin (t) * C2

y =

-sin (t) * C1 + cos (t) * C2

We then calculate the solution of the previous system of differential equations subject to the initial conditions x(0) = 0 and y(0) = 1.

>> [x, y] = dsolve('Dx = y, Dy = - x', 'x(0) = 0, y(0) = 1')
x =

sin(t)

y =

cos(t)

EXERCISE 6-1

Consider the following symbolic matrix A:

image

Calculate A', A-1, determinant(A), trace(A), rank(A) and A2.

We start by defining the symbolic form of our problem matrix as follows:

>> A=sym('[a,b,c; 3*c,a-3*c,b; 3*b,-3*b+3*c,a-3*c]')

A =
[   a,       b,    c]
[3*c,   a-3*c,    b]
[3*b,-3*b+3*c,a-3*c]

Alternatively, the same symbolic matrix can be defined by previously declaring all variables as symbolic, as follows:

>> syms a b c
>> A=sym([a,b,c; 3*c,a-3*c,b; 3*b,-3*b+3*c,a-3*c])

A =
[        a,        b,        c]
[      3*c,    a-3*c,        b]
[      3*b, -3*b+3*c,    a-3*c]

>> transpose(A)

ans =

[a, 3 * c, * 3B]
[b, a-3*c, -3*b+3*c]
[c,     b,    a-3*c]

>> pretty(inv(A))

    2              2      2                        2          2            2
 [a  - 6 a c + 9 c  + 3 b  - 3 b c       a b - 3 c        - b  + a c - 3 c ]
 [-------------------------------     - -----------     - -----------------]
 [                %1                          %1                   %1       ]
 [                                                                          ]
 [              2            2        2                                 2   ]
 [           - b  + a c - 3 c        a  - 3 a c - 3 b c        a b - 3 c    ]
 [       - 3 -----------------       ------------------      - ----------   ]
 [                   %1                      %1                    %1       ]
 [                                                                          ]
 [                       2                           2     2                ]
 [              a b - 3 c               a b - a c + b     a  - 3 a c - 3 b c]
 [         - 3 ----------            3 ---------------    ------------------]
 [                  %1                        %1                  %1        ]

        3        2      2          2                3      3        2
%1 :=  a  - 6 c a  + 9 c  a + 3 a b  - 9 a b c + 9 c  + 3 b  + 9 b c

>> pretty(det(A))

          3        2      2          2                3      3        2
         a  - 6 c a  + 9 c  a + 3 a b  - 9 a b c + 9 c  + 3 b  + 9 b c

>> pretty(trace(A))

                                   3 a - 6 c

>> rank(A)

ans =

     3

>> A^2

ans =

[               a^2+6*b*c,            a*b+b*(a-3*c)+c*(-3*b+3*c),          a*c+b^2+c*(a-3*c)]
[3*a*c+3*c*(a-3*c)+3*b^2,           3*b*c+(a-3*c)^2+b*(-3*b+3*c),           3*c^2+2*b*(a-3*c)]
[3*a*b+3*c*(-3*b+3*c)+3*b*(a-3*c),     3*b^2+2*(-3*b+3*c)*(a-3*c),   3*b*c+(a-3*c)^2+b*(-3*b+3*c)]

EXERCISE 6-2

Find the intersection of the hyperbolas with equations x2- y2= 1 and  a2x2- b2y2= 16 with the parabola z2 = 2 x.

We can solve the system formed by the three equations as follows:

>> [x, y, z] = solve('a^2*x^2-b^2*y^2=16','x^2-y^2=1','z^2=2*x','x,y,z')

x =

[  1/2*(((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4))^2]
[  1/2*(((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4))^2]
[1/2*(-((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4))^2]
[1/2*(-((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4))^2]
[  1/2*(((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4))^2]
[  1/2*(((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4))^2]
[1/2*(-((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4))^2]
[1/2*(-((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4))^2]

y =

[  1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]
[-1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]
[  1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]
[-1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]
[  1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]
[-1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]
[  1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]
[-1/(a^2-b^2)*(-(a^2-b^2)*(a^2-16))^(1/2)]

z =

[  ((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4)]
[  ((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4)]
[-((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4)]
[-((b^2-16)/(a^2-b^2))^(1/4)+i*((b^2-16)/(a^2-b^2))^(1/4)]
[  ((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4)]
[  ((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4)]
[-((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4)]
[-((b^2-16)/(a^2-b^2))^(1/4)-i*((b^2-16)/(a^2-b^2))^(1/4)]

EXERCISE 6-3

Solve the following integrals:

image

For the first integral the integrand is an even function, so the integral will be double the integral of the function between the limits 0 and 3. Then, we make the change of variable 2t = v, and arrive at the integral:

image

whose solution is given by MATLAB as follows:

>> (2/3) * (sinint(6))

ans =

    0.9498

To calculate the second integral we have in mind the following:

image

which can be calculated in MATLAB as follows:

>> cosint(5) - 0.577215664 - log(5)

ans =

   -2.3767

EXERCISE 6-4

Given the function h defined by h(x,y) = (cos(x2-y2), sin(x2-y2)), calculate h(1,2), h(-Pi,Pi) and h(cos(a2), cos(1-a2)).

We create a two-dimensional vector function as follows:

>> syms x y a.
>> h = [cos(x^2-y^2), sin(x^2-y^2)]

h =

[cos(x^2-y^2), sin(x^2-y^2)]

Now we calculate the requested values:

>> subs(h,{x,y},{1,2})

ans =

   -0.9900-0.1411

>> subs(h,{x,y},{-pi,pi})

ans =

     1 0

>> subs(h, {x,y}, {cos(a^2), cos(1-a^2)})

ans =

[cos(cos(a^2) ^ 2-cos(-1+a^2) ^ 2), sin(cos(a^2) ^ 2-cos(-1+a^2) ^ 2)]

EXERCISE 6-5

Given the function f defined by

f(x,y) = 3 (1-x)2 e-(y + 1) ^ 2-x ^ 2 -10(x/5-x3-y/5) e-x ^ 2 - y ^ 2-1/3e-(x + 1) ^ 2 - y ^ 2

find f(0,0) and represent the function graphically.

In this case, since it is necessary to represent the function, we define it via the M-file shown in Figure 6-2.

Now, we calculate the value of f at (0,0):

>> func2 (0,0)

ans =

    0.9810

To graph the function, use the command meshgrid to draw the graph on screen (in a neighborhood of the origin), and the command surf to generate the surface graph:

>> [x,y] = meshgrid(-0.5:.05:0.5,-0.5:.05:0.5);
>> z = func2(x,y);
>> surf(x,y,z)

The result is the graph shown in Figure 6-3.

EXERCISE 6-6

Given functions f(x) = sin(cos(x1/2) and g(x) = sqrt(tan(x2)), calculate the composite of f and g and the composite of g and f. Also calculate the inverse of the functions f and g.

>> syms x, f = (cos(x^(1/2)));
>> g=sqrt(tan(x^2));
>> simple(compose(f,g))

ans =

sin(cos(tan(x^2)^(1/4)))

>> simple(compose(g,f))

ans =

tan(sin(cos(x^(1/2)))^2)^(1/2)

>> F = finverse(f)

F =

acos(asin(x))^2

>> G = finverse(g)

G =

atan(x^2)^(1/2)

EXERCISE 6-7

Given the function defined as

image

study its continuity on the real line.

Except at the point x = 0, the continuity is clear. To analyze the function at the point x = 0 we calculate the lateral limits as x0:

>> syms x
limit(1/(1+exp(1/x)),x,0,'right')

ans =

0

>> limit(1/(1+exp(1/x)),x,0,'left')

ans =

1

The limit of the function as x0 does not exist, because the lateral limits are different. But because the lateral limits are both finite, the discontinuity at x = 0 is a finite jump. We can illustrate this result with the plot shown in Figure 6-4.

>> fplot('1/(1+exp(1/x))',[-5,5])

EXERCISE 6-8

Calculate the continuity of the function f: R2 image R defined by:

image

The only problem is at (1,0). To confirm that the function is continuous at this point, we need to check that

image

>> syms x y m a r
>> limit(limit(y ^ 2 *(x-1) ^ 2 / (y ^ 2 +(x-1) ^ 2), x, 0), y, 0)

ans =

0

>> limit(limit(y ^ 2 *(x-1) ^ 2 / (y ^ 2 + (x-1) ^ 2), y, 0), x, 0)

ans =

0

>> limit((m*x)^2*(x-1)^2/((m*x)^2+(x-1)^2),x,0)

ans =

0

>> limit ((m*x) *(x-1)^2/((m*x) +(x-1)^2),x,0)

ans =

0

It turns out that the iterated and directional limits (as calculated along a straight line y = mx) coincide, which leads us to believe in the existence of the limit and that its value is zero. To corroborate this, we can calculate the limit in polar coordinates:

>> limit(limit((r ^ 2 * sin(a) ^ 2) * (r * cos(a) - 1) ^ 2 / ((r ^ 2 * sin(a) ^ 2) + (r * cos(a) - 1) ^ 2), r, 1), a, 0)

ans =

0

We find that the limit is zero at the point (1,0), which ensures the continuity of the function. Figure 6-5 shows the surface, and in particular the continuity and the tendency toward 0 in a neighborhood of the point (1,0).

>> [x, y] = meshgrid(0:0.05:2,-2:0.05:2);
z=y.^2.*(x-1).^2./(y.^2+(x-1).^2);
mesh(x,y,z), view ([- 23, 30])

EXERCISE 6-9

Find the sum of the following series:

image

Before attempting to find the sums we first need to show that the sums are indeed convergent. We apply the ratio test for the first series:

>> syms n
>> f=(3+2*n)/((1-n)*n*7^n);
>> pretty(f)

                             3 + 2 n
                           ------------
                                      n
                           (1 - n) n 7

>> limit(subs(f,n,n+1)/f,n,inf)

ans =

1/7

As the limit is less than 1, the series is convergent. We will calculate its sum. MATLAB tries to return the result, which can be complicated. Often, the result returned depends on certain special functions defined by the program. Here’s an example:

>> S1 = symsum(f,n,2,inf)

S1 =

-6 * log(6/7)-22/21 + 13/343 * hypergeom([2, 2],[3],1/7)

Now we apply the ratio test to the second series:

>> syms n p
>> g=n/p^n;
>> pretty(g)

                                   n
                                 ----
                                   n
                                  p

>> limit(subs(g,n,n+1)/g,n,inf)

ans =

1/p

Thus, if p > 1, the series converges; if p < 1, the series diverges; and if p = 1, we get the series of general term n, which diverges. When p is greater than 1, we find the sum of the series:

>> S2=symsum(g,n,2,inf)

S2 =

2/p^2*(1/2/(-1+p)^3*p^4*(-1/p+1)-1/2*p)

>> pretty(simple(S2))

                               -1 + 2 p
                              -----------
                                        2
                              p (- 1 + p)

EXERCISE 6-10

Find the MacLaurin series up to order 13 of the function sinh(x). Also find the Taylor series up to order 6 of the function 1/(1+x) in a neighborhood of the point x = 1.

>> pretty(taylor(sinh(x),13))

                3          5           7             9               11
       x + 1/6 x  + 1/120 x  + 1/5040 x  + 1/362880 x  + 1/39916800 x

>> pretty(taylor(1/(1+x),6,1))

                           2               3               4               5
  3/4 - 1/4 x + 1/8 (x - 1)  - 1/16 (x - 1)  + 1/32 (x - 1)  - 1/64 (x - 1)

EXERCISE 6-11

Conduct a full study of the function

image

calculating the asymptotes, maximum, minimum, inflection points, intervals of growth and decrease, and intervals of concavity and convexity.

>>  f='x ^ 3 /(x^2-1)'

f =

x^3 /(x^2-1)

>> syms x, limit (x^3 /(x^2-1), x, inf)

ans =

NaN

We can see that there are no horizontal asymptotes. To see if there are any vertical asymptotes, let’s look at the values of x that make y infinite:

>> solve('x^2-1')

ans =

[1]
[-1]

The vertical asymptotes are the straight lines x = 1 and x =1. Now let's see if there are any oblique asymptotes:

>> limit(x^3/(x^2-1)/x,x,inf)

ans =

1

>> limit(x^3/(x^2-1)-x,x,inf)

ans =

0

The straight line y = x is an oblique asymptote. Now, the maximum and minimum, inflection points and intervals of concavity and growth will be analyzed:

>> solve(diff(f))

ans =

[         0]
[         0]
[3 ^(1/2)  ]
[^(1/2) - 3]

The first derivative vanishes at the points with x-coordinates x = 0, x =√3 and x = –√3. These include maximum and minimum candidates. To test whether they are maxima or minima, we find the value of the second derivative at those points:

>> [numeric(subs(diff(f,2),0)),numeric(subs(diff(f,2),sqrt(3))),
   numeric(subs(diff(f,2),-sqrt(3)))]

ans =

         0 2.5981 - 2.5981

Therefore, at the point with abscissa x= √3 there is a maximum and at the point with abscissa x = √3 there is a minimum. At x = 0 we know nothing:

>> [numeric(subs(f, sqrt(3))), numeric(subs(f, -sqrt(3)))]

ans =

    2.5981 - 2.5981

Therefore, the highest point is (image-,-2.5981) and the minimum point is (image).

We will now analyze the points of inflection:

>> solve(diff(f,2))

ans =

[            0]
[i*3^(1/2)   ]
[-i * 3 ^(1/2)]

The only possible turning point occurs at x = 0, and because f(0) = 0, this possible turning point is (0,0):

>> subs(diff(f,3), 0)

ans =

-6

As the third derivative at x = 0 is non-zero, the origin really is a turning point:

>> pretty(simple(diff(f)))

                              2   2
                            x  (x  - 3)
                            ------------
                                2   2
                             (x - 1)

The curve is increasing when y' > 0, that is, in the intervals  (-∞,-√3) and (√3,∞).

The curve is decreasing when y' < 0, that is, in the intervals

(-√3,-1),  (-1,0),  (0,1) and (1, √3).

>> pretty(simple(diff(f,2)))

                                   2
                              x (x + 3)
                           2 ------------
                                  2   3
                               (x - 1)

The curve is concave when y"> 0, that is, in the intervals (-1,0) and (1, ∞).

The curve is convex when y"< 0, that is, in the intervals (0,1) and (-∞ ,-1).

The curve has horizontal tangents at the three points at which the first derivative is zero. The equations of the horizontal tangents are y = 0, y = 2.5981 and y = -2.5981.

The curve has vertical tangents at the points that make the first derivative infinite. These include x = 1 and x =-1. Therefore, the vertical tangents coincide with the two vertical asymptotes.

We can then represent the curve along with its asymptotes as shown in Figure 6-6.

>> fplot('[x^3/(x^2-1),x]',[-5,5,-5,5])

We can also represent the curve, its asymptotes, and their horizontal and vertical tangents in the same graph (see Figure 6-7).

>> fplot('[x^3/(x^2-1),x,2.5981,-2.5981]',[-5,5,-5,5])

EXERCISE 6-12

Given the vector function (u(x,y), v(x,y)), where:

image

find the conditions under which there is an inverse vector function (x(u,v), y(u,v)) with x = x(u,v) and y = y(u,v) and find the derivative and the Jacobian of the inverse transformation. Find its value at the point (π/4,-π/4).

The conditions that must be met are the hypotheses of the inverse function theorem. The functions are differentiable with a continuous derivative, except perhaps at x= 0. Now let's consider the Jacobian of the direct transformation ∂(u(x,y), v(x,y)) /∂(x,y):

>> syms x y
>> J = simple((jacobian ([(x^4+y^4)/x, sin(x) + cos(y)], [x, y])))

J =

[3 * x^2 - 1/x^2 * y^4, 4 * y^3/x]
[cos(x),-sin(y)]

>> pretty(det(J))

                                4           4     3
                     3 sin (y) x - sin (y) y + 4 y cos (x) x
                   - ---------------------------------------
                                        2
                                       x

Therefore, at the points where this expression is non-zero, it can be solved for x and y in terms of u and v. In addition, it must also meet the requirement that x ≠ 0.

We next calculate the derivative of the inverse function. Its value is the inverse of the initial Jacobian matrix, and the determinant of the Jacobian is the reciprocal of the determinant of the Jacobian of the initial function:

>> I=simple(inv(J));
>> pretty(simple(det(I)))

                                        2
                                       x
                   - ---------------------------------------
                                4           4     3
                     3 sin (y) x - sin (y) y + 4 y cos (x) x

Next we are going to find the value of this function at the point (π/4,-π/4):

>> numeric(subs(subs(determ(I),pi/4,'x');-pi/4,'y'))

ans =

   0.38210611216717

>> numeric(subs(subs(symdiv(1,determ(J)),pi/4,'x');-pi/4,'y'))

ans =
   0.38210611216717

These results corroborate that the determinant of the Jacobian of the inverse function is the reciprocal of the determinant of the Jacobian of the original function.

EXERCISE 6-13

Given the function image and the transformation u = u(x,y) = x + y, v = v(x,y) = x, find f(u,v).

We calculate the inverse transformation and its Jacobian to apply the change of variables theorem:

>> syms x y u v
>> [x, y] = solve('u=x+y,v=x','x','y')

x =

v

y =

u-v

>> jacobian([v,u-v],[u,v])

ans =

[0, 1]
[1, - 1]

>> f = exp(x-y);
>> pretty(simple(subs(f,{x,y},{v,u-v}) * abs(det(jacobian([v, u-v], [u, v])))

                                 exp(2 v-u)

The requested function is f(u,v) = e2v-u.

EXERCISE 6-14

Solve the following integrals:

image

>> syms x
>> pretty(simple(int(x^(-3)*(x^2+3*x-1)^(-1/2),x)))

        2           1/2         2           1/2
      (x + 3 x - 1)          (x + 3 x - 1)
  1/2 ----------------- + 9/4 -----------------
              2                       x
             x

                             -2 + 3 x
         + 31/8 tie 1/2 (-)
                           2           1/2
                         (x  + 3 x - 1)

>> pretty(simple(int(x^(-1)*(9-4*x^2)^(1/2), x)))

                            2 1/2                 3
                    (9 - 4 x )    - 3 atanh(-------------)
                                                    2 1/2
                                            (9 - 4 x )

>> pretty(simple(int(x^8*(3+5*x^3)^(1/4),x)))

                                3        6         9          3 1/4
            4/73125 (288 - 120 x + 125 x + 1875 x) (3 + 5 x)

EXERCISE 6-15

Consider the curve given in polar coordinates by r = 3-3cos(a). Calculate the length of the arc corresponding to one complete revolution (0≤a≤2π).

>> r='3-3*cos(a)';
>> diff(r,'a')

ans =

3 * sin (a)

>> R = simple(int('((3-3 * cos(a))^2 + (3 * sin(a))^2)^(1/2)','a', '0','2 * pi'))

R =

24

EXERCISE 6-16

Calculate the value of the following integral

image

which represents the area under the normal curve between the specified limits.

>> numeric(int('exp(-x^2/2)/(2*pi)^(1/2)','x',-1.96,1.96))

ans =
   0.95000420970356

EXERCISE 6-17

Find the intersection of the paraboloid ax2 + y2 = z and the cylinder z = a2 - y2 and calculate the volume enclosed by the intersection. Also find the volume of the intersection of the cylinder z = x2 and 4 - y2 = z.

The first volume is calculated by means of the integral:

>> pretty(simple(int(int(int('1','z','a*x^2+y^2',
   'a^2-y^2');'y',0,'sqrt((a^2-a*x^2)/2)');'x',0,'sqrt(a)')))

       /
       |                 2       2        2 1/2
  1/24 |    lim       3 a  x (2 a  - 2 a x )
       |       1/2
       x -> (a   )-

                                1/2  1/2                              
              7/2  1/2         2    a    x           2      2 1/2     |
         + 3 a    2    atan(-------------- ) +  x (2a – 2ax  )        |
                                2        2 1/2                        |
                            (2 a  - 2 a x )                           /

To calculate the second volume we graph the requested intersection, as shown in Figure 6-8, with the aim of clarifying the limits of integration, using the following syntax:

>> [x, y] = meshgrid(-2:.1:2);
z = x ^ 2;
mesh(x,y,z)
hold on;
z = 4 - y. ^ 2;
mesh (x, y, z)

Now we can calculate the volume requested via the following integral:

>> pretty(simple(int(int(int('1','z','x^2','4-y^2');
   'y',0,'sqrt(4-x^2)');'x',0,2)))

                                     2 pi

EXERCISE 6-18

Solve the following differential equation:

image

>> pretty(simple(dsolve('Dy =(x*y)/(y^2-x^2)')))

                                             t + C1
                                    exp (-2)--------
                                                x
                   -1/2 lambertw(- ------------------) x - t - C1
                                           2
                                          x
               exp(-----------------------------------------------)
                                        x

EXERCISE 6-19

Solve the following equations:

image

image

image

>> pretty(simple(dsolve('9*D4y-6*D3y+46*D2y-6*Dy+37*y=0')))

C1 sin(t) + cos(t) C2 + C3 exp(1/3 t)sin(2t) + C4 exp(1/3 t)cos(2t)

>> pretty(dsolve('3*D2y+2*Dy-5*y=0'))

                          exp(t) C1 + C2 exp(-5/3 t)

>> pretty(dsolve('2 * D2y + 5 * Dy + 5 * y = 0', 'y (0) = 0 Dy (0) = 1/2 '))

                          1/2                        1/2
                   2/15 15 exp(-5/4 t) sin(1/4 15 t)

EXERCISE 6-20

With the initial conditions x(0) = 1 and y(0) = 2, solve the following system of equations:

image

image

>> [x,y] = dsolve('Dx-Dy = exp(-t), Dy+5 * x + 2 * y = sin(3 + t)','x(0) = 1, y(0) = 2')

x =

(-7/50 * sin(3) + 1/50 * cos(3) + 7/6) * exp(-7*t) + 7/50 * sin(3+t)-1/50 * cos(3+t)-1/6 * exp(-t)

y =

(-7/50 * sin(3) + 1/50 * cos(3) + 7/6) * exp(-7*t) + 5/6 * exp(-t) + 7/50 * sin(3+t)-1/50 * cos(3 + t)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset