для примера:
var n=0;
var x=1;
var plusY='';
var minusY='';
matanaliz(50);
function matanaliz(total){
var num = '';
for( var i=1; i <= total; i++ ){
n=i;
num = (Math.abs(Math.sin(n*x) - Math.cos(n/x)));
(num >= 0) ? (plusY += (num + '; (n='+n+',x='+x+') ' + '\t\n')) : (minusY += num + '; (n='+n+',x='+x+') ' + '\t\n');
}
console.log('plusY: '+plusY);
console.log('minusY: '+minusY);
};