Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Gradte Matlab
Gradte Matlab
funcion.m
function [fg,grd]=funcion(x)
% EN ESTA SUBRUTINA SE PONEN LA FUNCION QUE SE VA A OPTIMZAR, fg,
% Y EL GRADIENTE, grd. EL CASO QUE ESTA MONTADO CORRESPONDE AL
% PROBLEMA 2-A, DEL JUEGO DE EJERCICIOS 10.2, DEL LIBRO ANALISIS
% NUMERICO DE BURDEN Y FAIRES, EDICION N0. 9.
%
f1=3.0*x(1)-cos(x(2)*x(3))-1.0/2.0;
f2=4.0*x(1)^2-625.0*x(2)^2+2.0*x(2)-1.0;
f3=exp(-x(1)*x(2))+20.0*x(3)+(10.0*pi-3.0)/3.0;
fg=f1^2+f2^2+f3^2;
grd(1)=2.0*f1*3.0+2.0*f2*8.0*x(1)+2.0*f3*(-x(2)*exp(-x(1)*x(2)));
grd(2)=2.0*f1*x(3)*sin(x(2)*x(3))+2.0*f2*(-1250.0*x(2)+2.0)+2.0* ...
f3*(-x(1)*exp(-x(1)*x(2)));
grd(3)=2.0*f1*x(2)*sin(x(2)*x(3))+2.0*f3*20.0;
end
32
Funciones a las que se les desea sacar sus raices:
1
f1 x1 , x 2 , x 3 3x1 cosx 2 x 3 0
2
f 2 x1 , x 2 , x 3 4x12 625x 2 2 2x 2 1 0
10π 3
f 3 x1 , x 2 , x 3 e x 1 x 2 20x3 0
3
2
1
gx1 , x 2 , x 3 3x1 cosx 2 x 3 4x12 625x 2 2 2x 2 1
2
2
2
x1x 2 10π 3
e 20x3
3
quedando finalmente:
33
gradiente de g(x1,x2,x3):
1
2
13x cos x x
2 3 3
2
2 2
gx1, x 2 , x 3 2 4x1 625x 2 2x 2 1 8x1 ax1
2 e x 1 x 2 20x
3
10π
3
3
x x
x 2e 1 2
1
2
1 3x cos x x
2 3 x 3sen x x
2 3
2
2 2
2 4x1 625x 2 2x 2 1 1250x2 2 ax 2
2 e x1 x 2 20x
3
10π
3
3
x1e x1 x 2
1
2
1 3x cos x x
2 3 x 2 sen x x
2 3
2
ax 3
x1x 2 10π 3
2
e 20x 3 20
3
34
Quedando finalmente:
>> clear
>> gradte
Valor inicial de x(1) =>0.5
x0 =
0.5000
x0 =
0.5000 0.0500
x0 =
options =
Display: []
MaxFunEvals: []
MaxIter: []
TolFun: 1.0000e-005
TolX: 1.0000e-005
FunValCheck: []
OutputFcn: []
PlotFcns: []
35
ActiveConstrTol: []
Algorithm: []
AlwaysHonorConstraints: []
BranchStrategy: []
DerivativeCheck: []
Diagnostics: 'on'
DiffMaxChange: []
DiffMinChange: []
FinDiffType: []
GoalsExactAchieve: []
GradConstr: []
GradObj: 'on'
HessFcn: []
Hessian: []
HessMult: []
HessPattern: []
HessUpdate: []
InitialHessType: []
InitialHessMatrix: []
InitBarrierParam: []
InitTrustRegionRadius: []
Jacobian: []
JacobMult: []
JacobPattern: []
LargeScale: []
LevenbergMarquardt: []
LineSearchType: []
MaxNodes: []
MaxPCGIter: []
MaxProjCGIter: []
MaxRLPIter: []
MaxSQPIter: []
MaxTime: []
MeritFunction: []
MinAbsMax: []
NodeDisplayInterval: []
NodeSearchStrategy: []
NonlEqnAlgorithm: []
NoStopIfFlatInfeas: []
ObjectiveLimit: []
PhaseOneTotalScaling: []
Preconditioner: []
PrecondBandWidth: []
RelLineSrchBnd: []
RelLineSrchBndDuration: []
ScaleProblem: []
ShowStatusWindow: []
Simplex: []
SubproblemAlgorithm: []
TolCon: []
TolConSQP: []
TolGradCon: []
TolPCG: []
TolProjCG: []
TolProjCGAbs: []
TolRLPFun: []
TolXInteger: []
36
TypicalX: []
UseParallel: []
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Diagnostic Information
Number of variables: 3
Functions
Objective and gradient: funcion
Hessian: finite-differencing (or Quasi-Newton)
Algorithm selected
large-scale: trust-region Newton
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
End diagnostic information
x =
fval =
3.1682e-006
37