Docsity

Numerical Analysis: Assignment Problems 1-7, Exercises of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Assignment No 1
Problems 1-7:
Editor Code:
% Problem No 1:- Scalar Variables:
a=10
b=2.5*10^23
c=2+3i
d=exp(j*2*pi/3)
% Problem No 2:- Vector Variables:
aVec=[3.14 15 9 26]
bVec=[2.71;8;28;182]
cVec=[5:-0.2:-5]
dVec=[logspace(0,1,100)]
eVec=['Hellooo']
% Problem No 3:- Matrix Variables:
aMat=2*ones(9)
vecd=[1 2 3 4 5 4 3 2 1];
bMat=diag(vecd)
veck=[1:100];
cMat=reshape(veck,10,10)
dMat=nan(3,4)
eMat=[13 -1 5; -22 10 -87]
s=-3; %starting point of Range
e=3; %Ending point of range
fMat = (e-s).*rand(5,3) + s
% Problem No 4:- Scalar Equations:
x=1/(1+exp(-(a-15)/6))
y=(a^(1/2)+b^(1/21))^pi
rl=real((c+d)*(c-d));
z=(log(rl)*sin(a*pi/3))/(c*conj(c))
% Problem No 5:- Vector Equations:
xVec=(1./(sqrt((2*pi*(2.5^2)))))*(exp(-cVec.^2./(2.25^2)))
yVec=sqrt((aVec').^2+(bVec.^2))
zVec=log10(1./dVec)
% Problem No 6:- Matrix Equations:
xMat=(aVec * bVec)*(aMat.*aMat)
yMat=bVec * aVec
zMat=det(cMat) * (aMat*bMat)'
% Problem No 7:- Common Functions & Indexing:
cSum=sum(cMat)
eMean=mean(eMat,2)
r=[1 1 1];
Numerical Analysis: Assignment
C.No:- 08 |Farman-Ullah
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Numerical Analysis: Assignment Problems 1-7 and more Exercises Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Assignment No 1

Problems 1-7:

Editor Code:

% Problem No 1:- Scalar Variables:

a=

b=2.5*10^

c=2+3i

d=exp(j2pi/3)

% Problem No 2:- Vector Variables:

aVec=[3.14 15 9 26]

bVec=[2.71;8;28;182]

cVec=[5:-0.2:-5]

dVec=[logspace(0,1,100)]

eVec=['Hellooo']

% Problem No 3:- Matrix Variables:

aMat=2*ones(9)

vecd=[1 2 3 4 5 4 3 2 1];

bMat=diag(vecd)

veck=[1:100];

cMat=reshape(veck,10,10)

dMat=nan(3,4)

eMat=[13 -1 5; -22 10 -87]

s=-3; %starting point of Range

e=3; %Ending point of range

fMat = (e-s).*rand(5,3) + s

% Problem No 4:- Scalar Equations:

x=1/(1+exp(-(a-15)/6))

y=(a^(1/2)+b^(1/21))^pi

rl=real((c+d)*(c-d));

z=(log(rl)sin(api/3))/(c*conj(c))

% Problem No 5:- Vector Equations:

xVec=(1./(sqrt((2pi(2.5^2)))))*(exp(-cVec.^2./(2.25^2)))

yVec=sqrt((aVec').^2+(bVec.^2))

zVec=log10(1./dVec)

% Problem No 6:- Matrix Equations:

xMat=(aVec * bVec)(aMat.aMat)

yMat=bVec * aVec

zMat=det(cMat) * (aMat*bMat)'

% Problem No 7:- Common Functions & Indexing:

cSum=sum(cMat)

eMean=mean(eMat,2)

r=[1 1 1];

C.No:- 08 | Farman-Ullah

for i=

j=1:3;

eMat(i,j)=r(i,j)

end

cSub=zeros(8,8);

for i=1:8;

j=1:8;

cSub(i,j)=cMat(i+1,j+1);

end

cSub

lin=[1:20]

for j=1:

lin(2j)=-1lin(2*j);

end

lin

r=rand(1,5)

k=find(r<0.5)

r(k)=

Output at Command window:

a =

b =

2.5000e+

c =

2.0000 + 3.0000i

d =

-0.5000 + 0.8660i

aVec =

bVec =

C.No:- 08 | Farman-Ullah

Columns 67 through 77

Columns 78 through 88

Columns 89 through 99

Column 100

eVec =

Hellooo

aMat =

bMat =

cMat =

C.No:- 08 | Farman-Ullah

dMat =

NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

eMat =

fMat =

x =

y =

6.2696e+

z =

-2.7905 - 0.2093i

xVec =

Columns 1 through 11

Columns 12 through 22

Columns 23 through 33

Columns 34 through 44

C.No:- 08 | Farman-Ullah

Column 100

xMat =

1.0e+004 *

yMat =

1.0e+003 *

zMat =

cSum =

eMean =

C.No:- 08 | Farman-Ullah

eMat =

cSub =

lin =

Columns 1 through 19

Column 20

lin =

Columns 1 through 19

Column 20

r =

k =

r =

C.No:- 08 | Farman-Ullah