summaryrefslogtreecommitdiff
path: root/exam.sce
blob: 819d8d6a473a8cc3f2954e06e697b7b38eae4d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function y = fun(x) 
  y = 3*x(1)^2 + 2*x(1)*x(2) + x(2)^2 - 4*x(1) + 5*x(2) ;
endfunction

[xval, fval, status, gradient, hessian] = intfminunc(fun,[1 2],[2])

x1 = [0,-5];
x2 = [4,4];

[xval, fval, status, gradient, hessian] = intfminbnd(fun,[1],x1,x2)

		//Find x in R^6 such that it minimizes:
	    //f(x)= sin(x1) + sin(x2) + sin(x3) + sin(x4) + sin(x5) + sin(x6)
		//-2 <= x1,x2,x3,x4,x5,x6 <= 2
	    //Objective function to be minimised
	    function y=f(x)
			y=0
			for i =1:6
				y=y+sin(x(i));
			end	
		endfunction
		//Variable bounds  
		x1 = [-2, -2, -2, -2, -2, -2];
	  x2 = [2, 2, 2, 2, 2, 2];
    intcon = [];
		//Options
		[x,fval] =intfminbnd(f ,intcon, x1, x2)