Statistical and Optimization Methods for Engineers

Statistical and Optimization Methods for Engineers

Q1: a) Find the maxima and minima, if any, of the function

  1. b) Determine the convexity of the following function using the second derivative test.

Q2: Minimize 

  • Apply the bisection method with initial bounds  and
    with an error tolerance  Please present your search procedure
    in a tabular form.
  • Apply Newton’s method with an error tolerancePlease present
  • your search procedures in a tabular form.

Q3: The attached dataset (please download it separately from the blackboard)
was generated using the model:You are asked to use the dataset
to estimate the two parametersa1 and a2in the model, by treating it as a leastsquares problem.

Q4: Solve the following linear programming problem using the two methodsbelow:

  • The graphical solution;
  • The Simplex method;

Q5: Find the minimum value of the following function using LagrangeMultipliers: 

Solution

“`{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)

“`

$\underline{Question\: 1 : part\: (a)}$

$f(x)=4x^3-18x^2+27x-7 \:$

$\implies f'(x)=12x^2-36x+27$

For local minima/maxima , $f'(x)=0$ . So  $\: 12x^2-36x+27=0$.

$\: \implies 4x^2-12x+9=0 \: \implies$ $(2x-3)^2=0 \: \implies x=2/3$.

Now , $f”(x)=24x-36 \: \implies f”(\frac{2}{3})=0$.

So , $x=\frac{2}{3}$ is an inflection point. There is no minima or maxima of this function

$\underline{Question \:1 : part \:(b)}$

Here $f(x)=x^{2}+x^{4} \:$ $\implies f'(x)=2x + 4x^3 \:$ $\implies f”(x)=2+12x^2 \:$ $\implies f”(x)>0$ for all real $x$ , since $x^2 \geq 0$.

This proves that $\:f(x)$ is convex.

$\underline{Question\: 2 : part \:(a)}$

$f(x)=0.25x^4+2x^2-x^3-2x$

For minimization , we are seeking $x^{*}$ such that $f'(x^{*})=0$

“`{r}

derivative<- function(x){-3*x^2-2 + 4*x + x^3}

bisection_method<- function(a, b, tol, f ){

if (f(a)*f(b) > 0){

print(“No root found.”)

}

else

while ((b – a)/2.0 >tol){

midpt= (a + b)/2.0

if (f(midpt) == 0){

return(midpt) #The midpoint is the x-intercept/root.

}

else if (f(a)*f(midpt) < 0){ # Increasing but below 0 case

b = midpt

print(c(a,b))

}

else{

a = midpt

print(c(a,b))

}

}

return((a+b)/2)

}

bisection_method(0,2.4,tol=0.04,derivative)

derivative(1.0125)

“`

As you observe , The found $\:x^{*}=1.0125$ and the tabulation is as follows :-

“`{r}

#tabular form

iteration=c(1:5)

a=c(0.0,0.6,0.9,0.90,0.975)

b=c(1.2,1.2,1.2,1.05,1.050)

data.frame(iteration,a,b)

“`

$\underline{Question \:2 : part (b)}$

Our recursion is $x_{n+1}=x_{n}-\frac{f'(x_n)}{f”(x_n)}$

“`{r}

derivative<- function(x){-3*x^2-2 + 4*x + x^3}

second_derivative<- function(x){3*x^{2}-6*x+4}

x1=1.2 ; tol=0.001

for ( n in 1:10){

y=x1

x1=x1-{derivative(x1)}/{second_derivative(x1)}

print(x1)

if(abs(y-x1)<tol) {

break;

}

}

#tabulation of x_n

iteration=c(1,2,3)

x=c(1.014286,1.000006,1)

print(data.frame(iteration,x))

“`

Thus the answer turns out to be $x^{*}=1$ using Newton’s method.

$\underline{Question \: 3}$

“`{r}

library(readr)

Data_for_Assessment_2_2_ <- read_csv(“~/Desktop/Advent/Data_for_Assessment 2 (2).csv”)

z<-Data_for_Assessment_2_2_

library(nlmrt)

myformula<- y~a1*exp(x/a2)

parname<-c(“a1″=1,”a2″=1)

funss<-model2ssfun(myformula,pvec = parname)

fungr<-model2grfun(myformula,pvec = parname)

BFGS<-optim(par=parname,fn=funss,gr=fungr,method = “BFGS”,y=z$y,x=z$x)

print(BFGS)

“`

So, $\hat{a_1}=1.398 \:, \: \hat{a_2}=1.999$ are the optimal values to minimize the residual sum of squares .

$\underline{Question \: 4 \: part \:1}$

It’s enough to minimize $-18x_1-15x_2$ and add 20 to the answer .

“`{r}

library(intpoint)

a <- c(-18,-15)

A<- matrix(c(1,1,3,2),nrow = 2,byrow = T)

b <-c(5,12)

solve2dlp(t=-1,c=a,bm=b,m=A) #t=-1 since it’s a minimization problem.

“`

The optimal values is attained for $(x_1,x_2)=(2,3)$ and min value of $f=-18x_1-15x_2+20$ is $-81+20\: =\:-61$.

$\underline{Question \: 4 \: part \:2}$

We’ll use the simplex method . It’s enough to minimize $-18x_1-15x_2$ and add 20 to the answer .

“`{r}

library(boot)

a <- c(-18,-15)

A<- matrix(c(1,1,3,2),nrow = 2,byrow = T)

b <-c(5,12)

simplex(a,A,b)

“`

The optimal values is attained for $(x_1,x_2)=(2,3)$ and min value of $f=-18x_1-15x_2+20$ is $-81+20\: =\:-61$.

$\underline{Question \: 5}$

For minimum ,

$L=f-\lambda g=2x^2+y^2+3z^2-\lambda(2x-3y-4z-49)$

$\frac{\partial L}{\partial x}=\frac{\partial L}{\partial y} = \frac{\partial L}{\partial z}=\frac{\partial L}{\partial \lambda}=0$.

Therefore , $4x-2\lambda=2y+3\lambda=6z+4\lambda=0$…..(1)

So , at the extremum , $x=\frac{\lambda}{2}, \: y=\frac{-3\lambda}{2} , \: z=\frac{-2\lambda}{3}$…..(2)

Putting (*) in $2x-3y-4z=49$ ,

we get $\lambda = 6 \implies \:$ optimal solution is, $\:x=3 , \:y=-9 , \:z=-4$.

So, minimum value=$18+81+48=147$