0% found this document useful (0 votes)
13 views3 pages

Izz Kamal: %% Declaring Itteration Data

This document contains the solutions to two practical test questions: 1) Question 1 has two parts that involve defining and plotting a function, and using iteration to find the root of a function. 2) Question 2 has two parts involving linear programming to maximize a linear objective function subject to linear equality constraints. Part a maximizes a negative objective function, while part b maximizes a positive objective function. The solutions provide the optimal values of x and the maximum production.

Uploaded by

shamsukarim2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Izz Kamal: %% Declaring Itteration Data

This document contains the solutions to two practical test questions: 1) Question 1 has two parts that involve defining and plotting a function, and using iteration to find the root of a function. 2) Question 2 has two parts involving linear programming to maximize a linear objective function subject to linear equality constraints. Part a maximizes a negative objective function, while part b maximizes a positive objective function. The solutions provide the optimal values of x and the maximum production.

Uploaded by

shamsukarim2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

IZZ KAMAL

PRACTICAL TEST 1

Q1a
clear all
clc

q=@(x)(sqrt(0.0002))*((2*x)^(5/3))/0.03*((2+(2*x))^2/3)';

hi=0
hf=10
z= q(hi)
y= q(hf)
k=[ 0 10 ]
l=[ z y ]
plot(k,l);

Q1b

clear all
clc

F=@(x) sqrt(0.0002)*((2*x)^(5/3))/0.03*((2+(2*x))^2/3);

%% declaring itteration data


xl=0.01; xu=0.11; xr=0 ;es=0.1;imax=11;

Fl=F(xl); Fu=F(xu);

%% follow the flow


for i=1:imax;
if Fl*Fu==0
disp('Itteration Completed2')
fprintf('Xr',xu)
break
else
xm=xr;
xr=(xl+xu)/2;
ea=abs(xr-xm)/2;
Fr=F(xr);
disp('Itteration, xl, xu, xr,f(xr), ea')
disp(i,xl,xu,xr,f(xr),ea,'\n')
if ea<es
fprintf('itteration Completed')
break
end
if Fl*Fu<0;
xl=xr;
Fl=Fr;
else Fl*fr>0
xu=xr;
Fu=Fr;
end
end
end

Q2a
clear all
clc

%% Declaration Of The Given Data


f=[800 1000];
A=[-1 0; 1 0; 0 -1;0 -1; 4 5; -2 -3];
b=[2; 5; 2; 6; 40; 12];

%% Using linprog command for optimization process


[x,MaxProd]=linprog(-f,A,b)
[x,MaxProd]=linprog(f,A,b)

Q2b
Optimization terminated.

x=

-1.6020
9.2816

MaxProd =

-8.0000e+03

Optimization terminated.

x=

-2.0000
-2.0000
MaxProd =

-3.6000e+03

>>

You might also like