function [f,fp]=testfun1(x,q)

% function [f,fp]=testfun1(x,q)
% f=f(x,q)
% fp=f_x(x,q)

if nargin < 2,disp('testfun1 tarvitsee kaksi  argumenttia!');return,end
if max(size(x))<2,disp('Edellisen argumentin on oltava vektori!');return,end
a=mod(round(10*q(1)),11)-5;if a==0,a=2;end
c=[a.^5-23*a.^3,-3*a.^4+94*a,51*a.^2-120]/exp(abs(a)+1);
q=c(2:3);v=[2*c(2)*x(2)-x(1)*2*c(3),x(1)*gamma(3)*c(1)];
x=x(:);f=c(1)*(x(1)-x(2))^2;
fp=[c(3)*x(2)*2+2*c(1)*x(1)+2*c(2)*x(2)+2*x(2)*q(2),-2*c(1)*x(1)];
f=f+q(1)*x(1)^2+ c(3)*(x(1)+x(2))^2;fp=fp-v(2:-1:1);
return, endfunction
