Matlab Pesentation2 PDF
Matlab Pesentation2 PDF
Matlab Pesentation2 PDF
A L I G H A MA RTA L A
Engineering Analysis
Instructor: Dr. Jagath Nikapitiya
2
Modified Bessel functions
• Modified Bessel function K ( Z ) besselk(nu,Z)
x=0:0.01:5;
y0=besselk(0,x);
y1=besselk(1,x);
y2=besselk(2,x);
plot(x,y0)
hold on
plot(x,y1)
hold on
plot(x,y2)
axis([0 5 0 8])
legend('k_0', 'k_1', 'k_2')
xlabel('X')
ylabel('Bessel function')
title('Plot of Comparing different Modified Bessel function')
3
Modified Bessel functions
• Modified Bessel function I ( Z ) besseli(nu,Z)
x=0:0.01:5;
y0=besseli(0,x);
y1=besseli(1,x);
y2=besseli(2,x);
plot(x,y0)
hold on
plot(x,y1)
hold on
plot(x,y2)
axis([0 5 0 8])
legend('I_0', 'I_1', 'I_2')
xlabel('X')
ylabel('Bessel function')
title('Plot of Comparing different Modified Bessel function')
4
Elliptic Integral
Find Complete Elliptic Integrals of First kind
M = 0.5;
ellipticK(M)
---Result
1.8541 => the first kind
Find Complete Elliptic Integrals of second kind
M = 0.5;
ellipticE(M)
---Result
1.3506 => the second kind
Find Complete Elliptic Integrals of First and Second Kind
M = 0.5;
[K,E] = ellipke(M)
--- Result
K = 1.8541 => the first kind
E = 1.3506 => the second kind
5
Analytical Calculation
6
Analytical Calculation
7
Analytical Calculation
Function Example
𝑑𝑓
diff(function, variable) 𝑑𝑥
⇒ diff(f, x)
+𝑏
int(function, variable, lower bound, upper bound) −𝑏 𝑓 𝑑𝑥 ⇒ int(f, x, -b, +b)
symsum(function, variable, lower bond, upper bond ) σ3𝑛=0 𝑓(𝑛, 𝑥, … ) = symsum(f, n, 0, 3)
subs(function, variable) subs(f, x, 2) ⇒ 4*a + 2*b + c
• expand((x+1)^3) ⇒ x^3+3*x^2+3*x+1
expand(function) • expand(sin(x+y)) ⇒ sin(x)*cos(y)+cos(x)*sin(y)
• expand(exp(x+y)) => exp(x)*exp(y)
• simplify(sin(x)^2 + cos(x)^2) ⇒ 1.
simplify(function) • simplify(exp(c*log(sqrt(alpha+beta)))) ⇒ (alpha + beta)^(c/2).
• simplify(sqrt(x^2)) ⇒ sqrt(x^2),
f = a*x^2+b*x+c ⇒
solve(f, x)⇒
solve(function, variable) x1 = -(b + (b^2 - 4*a*c)^(1/2))/(2*a)
x2 = -(b - (b^2 - 4*a*c)^(1/2))/(2*a)
8
Example
Q = ( x 2 − a 2 ) ( y 2 − b 2 ) (a1 + a2 ( x 2 + y 2 ) + a3 x 2 y 2
Q Q Q
2 2
f = + + 2cQ
x x y
syms x y a b a1 a2 a3 c X Y n
Q = (x^2-a^2)*(y^2-b^2)*(a1+a2*(x^2+y^2)+a3*x^2*y^2);
Diff_x = diff(Q,x);
(a^2 - x^2)*(b^2 - y^2)*(2*a3*x*y^2 + 2*a2*x) - 2*x*(b^2 - y^2)*(a1 + a2*(x^2 + y^2) ….
f= (Diff_x)^2 + (diff(Q,y))^2 + 2*c*Q;
(2*y*(a^2 - x^2)*(a1 + a2*(x^2 + y^2) + a3*x^2*y^2) - (a^2 - x^2)*(b^2 - y^2)*(2*a3*y*x^2 +…
a b
h=
− a −b
f yx
h=int(int(f,y,-b,b),x,-a,a);
(128*a^9*a2^2*b^3)/945 + (256*a^9*a2*a3*b^5)/4725 + (1408*a^9*a3^2*b^7)/33075 +...
9
Example
Q = ( x 2 − a 2 ) ( y 2 − b 2 ) (a1 + a 2 ( x 2 + y 2 ) + a3 x 2 y 2
h
S= → solve for a1
a1
k=diff(h,a1);
S= solve(k,a1);
-(8*a3*a^4*b^2 + 40*a2*a^4 + 8*a3*a^2*b^4 + 112*a2*a^2*b^2 + 40*a2*b^4 ....
h
T=
a2 a1 = S
Subs_a1_2 = subs(diff(h,a2),a1,S);
(256*a^3*a2*b^9)/945 + (3328*a^5*a2*b^7)/1575 + (3328*a^7*a2*b^5)/1575 + ...
10
Example
Q = ( x 2 − a 2 ) ( y 2 − b 2 ) (a1 + a 2 ( x 2 + y 2 ) + a3 x 2 y 2
3
−1n cosh( x) cos( y ) (2n + 1)
=
( 2n + 1) 3 cosh( a)
3
n =0 2b
Landa = (2*n+1)*pi/(2*b);
Part = symsum(((-1)^n*cosh(Landa*x)*cos(Landa*y))/((2*n+1)^3*pi^3*cosh(Landa*a)) , n , 0 , 3);
(281474976710656*cosh((pi*x)/(2*b))*cos((pi*y)/(2*b)))/(8727491006471547*cosh((pi*a)/(2*b)))
-…
11
Example
QQ3 =(5540625*(- 4*X^2*b^2 + 4*b^2)*(- Y^2*b^2 + b^2)*((44003*c)/(394000*b^2) +
(1281*c*(4*X^2*b^2 + Y^2*b^2))/(78800*b^4) +
(189*X^2*Y^2*c)/(24625*b^2)))/(1263224*b^2*c)
A= simplify(QQ3)
(225*(X^2 - 1)*(Y^2 - 1)*(3024*X^2*Y^2 + 25620*X^2 + 6405*Y^2 + 44003))/5052896
B=expand(A)
(42525*X^4*Y^4)/315806 + (4725*X^4*Y^2)/4696 - (1441125*X^4)/1263224 +
(760725*X^2*Y^4)/5052896 + (1687725*X^2*Y^2)/2526448 - (4136175*X^2)/5052896 -
(1441125*Y^4)/5052896 - (4229775*Y^2)/2526448 + 9900675/5052896
12
Solve Equations
13
Solve by “fsolve”
• fsolve:
eqn = @(x) besselj(nu, x) ;
x0 = [first guess] ;
x = fsolve(eqn,x0)
-------------------------------------------------------
eqn = @(x) besselj(0, x) ;
x0 = [2, 5, 8, 11, 14] ; OR x0=0:20
x = fsolve(eqn,x0)
Result:
x=
14
Solve by code
c1*0.5767 + c2*(-0.1070)= 2 OR
16
Solve two equality simultaneously
Question: Calculate ‘u’ and ‘v’ Question: Calculate ‘c1’ and ‘c2’
2*u + v = 0
u-v=1 funcs=[c1*besselj(1, 1) + c2*bessely(1, 1) == 1,
syms u v c1*besselj(1, 2) + c2*bessely(1, 2) == 2];
17
18