SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
Maple Code for Steepest Descent
func:= (x,y) -> x^2 – y;
initx := 1;
inity := 1;
funcx := diff(func(x,y),x);
funcy := diff(func(x,y),y);
a1 := initx;
b1 := inity;
for I from 1 to 20 do
a := a1;
b:= b1;
currentval := evalf(func(a,b));
print(`current a ` = a, `current b` = b, `current val` = currentval);
fxpoint := evalf(subs({x = a, y = b}, funcx);
fypoint := evalf(subs({x = a, y = b},funcy);
print(`current gradient` = [fxpoint,fypoint]);
pathdiff := diff(func(a+fxpoint*t, b+ fypoint*t),t);
tmin := fsolve(pathdiff, t=0);
a1 := a + tmin*fxpoint;
b1 := b + tmin* fypoint;
func(a1,b1);
od:

Weitere ähnliche Inhalte

Was ist angesagt?

programa suma y multiplica
programa suma y multiplicaprograma suma y multiplica
programa suma y multiplicaMaria Amaro
 
Creative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesCreative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesTill Nagel
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Dr. Loganathan R
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c mohdshanu
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Dr. Loganathan R
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Dr. Loganathan R
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersDr. Loganathan R
 

Was ist angesagt? (20)

week-8x
week-8xweek-8x
week-8x
 
programa suma y multiplica
programa suma y multiplicaprograma suma y multiplica
programa suma y multiplica
 
Creative Coding 1 - 2 Variables
Creative Coding 1 - 2 VariablesCreative Coding 1 - 2 Variables
Creative Coding 1 - 2 Variables
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
 
2 d rotation
2 d rotation2 d rotation
2 d rotation
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Assignmnt 4
Assignmnt 4Assignmnt 4
Assignmnt 4
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
C programs pbq final
C programs pbq finalC programs pbq final
C programs pbq final
 
week-4x
week-4xweek-4x
week-4x
 
Tipos de funciones
Tipos de funcionesTipos de funciones
Tipos de funciones
 
PROYECTO PEDRO
PROYECTO PEDROPROYECTO PEDRO
PROYECTO PEDRO
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 
Faisal
FaisalFaisal
Faisal
 
Metnum
MetnumMetnum
Metnum
 
Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 

Mehr von Jeremy Lane

Mahalanobis Distance R
Mahalanobis Distance RMahalanobis Distance R
Mahalanobis Distance RJeremy Lane
 
Hypothesis Testing
Hypothesis TestingHypothesis Testing
Hypothesis TestingJeremy Lane
 
torsionbinormalnotes
torsionbinormalnotestorsionbinormalnotes
torsionbinormalnotesJeremy Lane
 

Mehr von Jeremy Lane (6)

DurbinWatsonVBA
DurbinWatsonVBADurbinWatsonVBA
DurbinWatsonVBA
 
SAS example
SAS exampleSAS example
SAS example
 
Mahalanobis Distance R
Mahalanobis Distance RMahalanobis Distance R
Mahalanobis Distance R
 
Hypothesis Testing
Hypothesis TestingHypothesis Testing
Hypothesis Testing
 
torsionbinormalnotes
torsionbinormalnotestorsionbinormalnotes
torsionbinormalnotes
 
shrinkingcircle
shrinkingcircleshrinkingcircle
shrinkingcircle
 

Maple Code for Steepest Descent

  • 1. Maple Code for Steepest Descent func:= (x,y) -> x^2 – y; initx := 1; inity := 1; funcx := diff(func(x,y),x); funcy := diff(func(x,y),y); a1 := initx; b1 := inity; for I from 1 to 20 do a := a1; b:= b1; currentval := evalf(func(a,b)); print(`current a ` = a, `current b` = b, `current val` = currentval); fxpoint := evalf(subs({x = a, y = b}, funcx); fypoint := evalf(subs({x = a, y = b},funcy); print(`current gradient` = [fxpoint,fypoint]); pathdiff := diff(func(a+fxpoint*t, b+ fypoint*t),t); tmin := fsolve(pathdiff, t=0); a1 := a + tmin*fxpoint; b1 := b + tmin* fypoint; func(a1,b1); od: