Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

UNIT-2_MATLAB Programs

Nothing
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

UNIT-2_MATLAB Programs

Nothing
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

UNIT-2

1. Find the nth derivative of the following


(i) cos5 x cos3x (ii) ex sin 3 x (iii) e2 x cos x cos 2 x
. Hence compute the same for n=5. Write an appropriate
MATLAB Code and verify your answer.

(i) syms x

%define a function

f=cos(5*x)*cos(3*x)

%5th derivative of the fucntion

diffn=simplify(diff(f,x,5))

out put

diffn =

- 16*sin(2*x) - 16384*sin(8*x)
(ii)

syms x

%define a function

g=exp(x)*sin(sqrt(3)*x)

%5th derivative of the function

diffn=simplify(diff(g,x,5))

output:

diffn =

-32*exp(x)*cos(pi/6 + 3^(1/2)*x)
(iii) syms x

%define a function

h=exp(2*x)*cos(x)*cos(2*x)

%5th derivative of the function

diffn=simplify(diff(h,x,5))

output:

diffn =

-exp(2*x)*(202*cos(x) + 319*sin(x) - 244*cos(x)^3 -


1194*cos(x)^2*sin(x))
log x  (1)n n! 
2. Show that Dn 
1 1 1
  n1  log x  1    ......   .Hence the
 x  x  2 3 n
result when n=5 and Also an appropriate MATLAB code to
verify the same.

Code:
syms x

%define a function

f1=log(x)/x

%1st derivative of the functtion

diffn=simplify(diff(f1,x,1))

%2nd derivative of the functtion

diffn=simplify(diff(f1,x,2))

%5th derivative of the functtion

diffn=simplify(diff(f1,x,5))
Output:

diffn =

-(log(x) - 1)/x^2

diffn =

(2*log(x) - 3)/x^3

diffn =

-(2*(60*log(x) - 137))/x^6

 
3. If y  cos log x2  2 x  1  show that

 x  12 yn2   2n  1 x  1 yn1   n2  4  yn  0 .

(verify the result for n=5)

syms x
%define a function
f=cos(log(x^2-2*x+1));
n=5;
%(n+2)th derivative of the function
A = simplify(diff(f,x,n+2));
%(n+1)th derivative of the fucntion
B = simplify(diff(f,x,n+1));
% nth derivative of the fucntion
C = simplify(diff(f,x,n));
result = simplify((x-1)^2*A+(2*n+1)*(x-1)*B+(n^2+4)*C)
if (result == 0)
disp("Given is proved")
else
disp("It is not correct")
end

4. Apply Taylor’s series method to expand loge (cos x) in powers


4
 
of  x   by up to terms containing  x   .Write an
 3  3
appropriate MATLAB code.

T = taylor(f,var) T =
taylor(f,var) approximates f wit
h the Taylor series
expansion of f up to the fifth
order at the point var = 0. If
you do not specify var,
then taylor uses the default
variable determined
by symvar(f,1).
T = taylor(f,var,a) T =
taylor(f,var,a) approximates f w
ith the Taylor series expansion
of f at the point var = a.
T = T =
taylor(___,Name,Valu taylor(___,Name,Value) specifies
e) options using one or more name-
value arguments in addition to
any of the input argument
combinations in previous
syntaxes. For example, you can
specify the expansion point,
truncation order, or order mode
of the Taylor series expansion.

syms x
%define the funciton
f=log(cos(x))
%Taylors series is upto first five non-zero terms
T1= taylor(f,x,pi/3)
%using ExapansioPoing
T2 = taylor(f,x,"ExpansionPoint", pi/3)
%Using trunction order
T3 = taylor(f,x,"ExpansionPoint", pi/3,"Order",7)

x 2 x 4 x6
5. Show that log e  sec x      ......... by using Maclaurin’s
2 12 45
series. Write an appropriate MATLAB code and the plot
the same.

Code:

syms x
%define the funciton
T = taylor(log(sec(x)),x,"Order",10)

Output:

T =

x^2/2 + x^4/12 + x^6/45 + (17*x^8)/2520


6. Apply Maclaurin’s series to expand loge (1  cos x) up to the
term containing x 4 .Write a MATLAB code to get series in
ascending powers of x.

syms x
%define the function
T = taylor(log(1+cos(x)))

Output:
T =

log(2) - x^2/4 - x^4/96

7. Evaluate the following


3x
 1x 1 1 
log(1  x)  1 2 x 3 x
(i) lim    
1
 (ii) lim 
x 


.Write an
x 0  x x2  3
appropriate MATLAB code
Mathematical Operation MATLAB Command
f(x) limit(f)
limx→0
f(x) limit(f, x, a) or
limx→a
limit(f, a)
f(x) limit(f, x, a, 'left')
limx→a−
f(x) limit(f, x, a, 'right')
limx→a+

Code:
syms x
%define a function
f = 1/x-log(1+x)/x^2
% limit of a function at x tends to 0
Lim_val=limit(f,x,0)
Output:
Lim_val=
1/2
(ii)
syms x
%define a function
g = ((1^(1/x)+2^(1/x)+3^(1/x))/3)^(3*x)
% limit of a function at x tends to 0
Lim_val1=limit(g,x,inf)
Output:
im_val1 =
6
Evaluate the following:
1
(i) lim   x  (ii) lim 
1 1 sinx  x2
 . Write an appropriate
x0  x e  1  x0  x 

MATLAB code.

8. Evaluate the following:


1
 ax  bx  cx  x
(i) lim  
1 1
  (ii) lim   .Write an
x2  x  2 log( x  1)  x0  3 
appropriate MATLAB code.

Code:
syms x
%define a function
kkkf = 1/(x-2)-log(x-1)

% limit of a function at x tends to 0


Lim_val=limit(f,x,2)

Output:
Lim_val =

-1/2
(ii)
syms x a b c
%define a function
g = ((a^x+b^x+c^x)/3)^(1/x);
% limit of a function at x tends to 0
Lim_val1=limit(g,x,0)
Output:
Lim_val1 =

a^(1/3)*b^(1/3)*c^(1/3)
9. Evaluate the following:
1  sin x  cos x  log(1  x) 
lim   . Write an appropriate MATLAB code.
x 0  x tan 2 x 

Code:
%define a function
f2 = ((1+sin(x)-cos(x)+log(1-x))/(x*(tan(x))^2));
% limit of a function at x tends to 0
Lim_val2=limit(f2,x,0)
Output:
Lim_val2 =

-1/2

10.Evaluate the following:


1
(i) lim   x  (ii) lim 
1 1 sinx  x2
 . Write an appropriate
x0  x e  1  x0  x 

MATLAB code.

syms x

%define a function

f3=1/x-1/(exp(x)-1)

% limit of a function at x tends to 0

Lim_val3=limit(f3,x,0)

Output:
Lim_val3 =

1/2
(ii)
syms x
%define a function
f4 = (sin(x)/x)^(1/x^2)
% limit of a function at x tends to 0
Lim_val4=limit(f3,x,0)
Output:
Lim_val4 =

1/2

You might also like