//M. Forets           @  iie    2011
unit testCase1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,
  xMatDefs, Math;

//devuelve el número de variables del problema (x)
function numeroDeVariables: Integer;

//evalúa la función para un x particular
function testCase1(x: TDAofNReal): NReal;


implementation

function numeroDeVariables: Integer;
begin
     Result := 6;
end;

function testCase1(x: TDAofNReal): NReal;
var
   auxR  :            NReal;
   i     :            Integer;
begin
     //writeln('x[0] =  ', x[0], '    x[1] = ',x[1]);
     if (x[0]>0) then
        begin
        auxR := -(x[0]-15.0)/(1.0+power(abs(x[0]-15.0), 1.1))*(x[0]-30.0)/(2.0+power(abs(x[0]-30.0), 1.4));

        end
     else
        auxR:=0.0;

     for i:=1 to length(x)-1 do
     begin
       auxR:=auxR/(1+sqr(abs(x[i]-5.0)));
     end;
     Result:=auxR + 15.0;
     //writeln('para los valores anteriores de x, resulta f = ',Result);
     //writeln('');

end;

end.

