1

I've been trying to create my own JavaScript program for solving problems in Calculus such as taking the derivative of an equation, but as of yet have not succeeded. I would be greatly appreciative if someone could help me with this.

4

1 回答 1

4

这样的事情应该这样做

function poly(variable, degree){
 return degree*((variable)^(degree-1));
}

您应该将 n 次多项式存储在 (n+1) 'array' 中并使用 Jquery 每种方法

var result = 0;
$.each(array, function(index, value) {
  result = result + poly(value,index);
});

编辑:如果您不了解 jquery,您可以使用纯 javascript for 循环,for (var i = 0; i < myArray.length; i++) {...}

于 2013-02-18T00:03:43.803 回答