Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

LABORATORY ACTIVITY #3

IN
NUMERICAL METHODS AND ANALYSIS

Optimization using Excel and MATLAB/Octave

GROUP 2:
PABLO, HARRISON P.
CORTEZ, MICHAEL ANGELO
RIVERA, CRIS ERROL
BS CPE 3A

ENGR. BELJAN MARZAN


TABLE OF CONTENTS

Front page
Table of Contents
I. INTRODUCTION
A. Activity Description
B. Objectives
C. Materials
II. ACTIVITY DETAILS
A. UNCONSTRAINED OPTIMIZATION
1. Analytical method
2. EXCEL
a. Golden-Section Search
b. Parabolic Interpolation
c. Newton’s Method
3. MATLAB
a. fminbnd function
B. CONSTRAINED OPTIMIZATION
1. Analytical Method
2. EXCEL
a. Excel Solver
3. MATLAB
a. fminsearch function
III. Conclusion
I. INTRODUCTION

A. Activity Description
This experiment aims to maximize the value of a function using both constrained and
unconstrained optimization strategies. In certain numerical case studies, Excel Solver is used to generate
the answer. Excel and MATLAB are utilized to execute an iterative procedure involving the Golden-
Section Search, Parabolic Interpolation, and Newton's Method.

B. Objectives
• Carry out the numerical methods of the case study while sticking to the restricted optimization
concept.
• Develop software that can be used for both limited and unconstrained optimization of a function
to discover its maximum.
• Calculating the maximum value of a function of a single variable f using open and bracketing
approaches (x).

C. Materials
 Excel
 Matlab
UNCONSTRAINED OPTIMIZATION

Employ the following methods to find the maximum of

f (x) = 4x - 1.8x2 + 1.2x3 - 0.3x4


2. Numerical methods using Excel
a. Golden-Section Search (xl = -2, xu = 4, εs = 0.0001%)
b. Parabolic Interpolation (x0 = 1.75, x1 = 2, x2 = 2.5, εs = 0.0001%)

c. Newton’s Method (x0 = 3, εs = 0.0001%)


3. MATLAB/Octave using fminbnd function (xl = -2, xu = 4, εs = 0.0001%)

Program:
Using the fminbnd function to get the maximum
x = linspace(-2,4,101);

f = @(x) 4*x - 1.8*x.^2 + 1.2*x.^3 - 0.3*x.^4;

[xMin, yMin] = fminbnd(f,-2,4);

g = @(x) -f(x);

[xMax, NegYMax] = fminbnd(g,-2,4);


fprintf(‘Xmax = \n %.5f \n’, xMax)
Ymax = -NegYMax;
fprintf(‘Ymax = \n %.5f \n’, Ymax)

plot(x,-g(x))
hold on;
plot(xMax, Ymax, '*');
text(xMax, Ymax, '\leftarrow Maximum');
xlabel('X');
ylabel('f(x)');
title('Maximum value of a function');

Result: Graph:
CONSTRAINED OPTIMIZATION

A computer equipment manufacturer produces scanners and printers. The resources needed for
producing these devices and the corresponding profits are

If there are $127,000 worth of capital and 4270 hr of labor available each day, how many of each
device should be produced per day to maximize profit?
2. Excel Solver
III. Conclusion
In this lab, we will examine a number of unconstrained optimization strategies for addressing
a variety of problems, as well as a number of approaches to the problem at hand. In addition,
we can determine the maximum value of each problem using Excel and Matlab, which assists
us in obtaining the desired solutions.

You might also like