// Example file for nag_intext4b which demonstrates the // linking of nag_multid_quad_adapt_1 (d01wcc) into Scilab // which uses a User defined function written in Scilab ndim = 4; a = [0; 0; 0; 0]; b = [1; 1; 1; 1]; minpts = 0; maxpts = 1e6; eps = 0.0001; finval_exp = 0.5754; acc_exp = 9.89e-05; tol = 1e-3; // * Function describing the integrand for the NAG routine d01wcc * // *==============================================================* deff('u=fUser(uu,z)',['tmp_pwr = z(2)+1.0+z(4)'; 'u = z(1)*4.0*z(3)*z(3)*exp(z(1)*2.0*z(3))/(tmp_pwr*tmp_pwr)']); // Alternative way of defining the Scilab function //function [u] = fUser(uu,z) // tmp_pwr = z(2)+1.0+z(4); // u = z(1)*4.0*z(3)*z(3)*exp(z(1)*2.0*z(3))/(tmp_pwr*tmp_pwr); //endfunction [finval,acc,minpts,fail] = nag_multid_quad_funb(ndim,a,b,minpts,maxpts,eps) ok1 = abs(finval - finval_exp)/abs(finval_exp) < tol ok2 = abs(acc - acc_exp)/abs(acc_exp) < tol if ~ok1; write(%io(2),'Error in expected output'); end; if ~ok2; write(%io(2),'Error in expected output'); end;