fnsqrec.gms : Test correctness of sqrec intrinsic

Description

sqrec(x,S) = 1/x                     if x >= S
             1/S - r/S^2 + r^2/s^3   otherwise, r = x - S
for S >= 1e-10, default S = 1e-10.

Contributor: Steve, Mar 2017


Small Model of Type : GAMS


Category : GAMS Test library


Main file : fnsqrec.gms   includes :   fnset_xy.inc [htmlfntest_xy.inc [html]

$title 'Test correctness of sqrec intrinsic' (FNSQREC,SEQ=727)

$onText
sqrec(x,S) = 1/x                     if x >= S
             1/S - r/S^2 + r^2/s^3   otherwise, r = x - S
for S >= 1e-10, default S = 1e-10.

Contributor: Steve, Mar 2017
$offText

$include fnset_xy.inc

$gdxIn fnsqrec
$load aeps reps relToInput T data
$gdxIn

loop {T,
  data(T,  'f')  = sqrec.value(   data(T,'x'),data(T,'y'));
  data(T, 'fx')  = sqrec.grad(1:  data(T,'x'),data(T,'y'));
  data(T, 'fy')  = sqrec.grad(2:  data(T,'x'),data(T,'y'));
  data(T,'fxx')  = sqrec.hess(1:1:data(T,'x'),data(T,'y'));
  data(T,'fxy')  = sqrec.hess(1:2:data(T,'x'),data(T,'y'));
  data(T,'fyx')  = sqrec.hess(2:1:data(T,'x'),data(T,'y'));
  data(T,'fyy')  = sqrec.hess(2:2:data(T,'x'),data(T,'y'));
  data(T, 'rc')  = mathlastrc;
  data(T, 'ec')  = mathlastec;
};

$include fntest_xy.inc