How to create a calculus derivative solver using Javascript? [closed]

邮差的信 提交于 2019-12-11 11:06:48

问题


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.


回答1:


Something like that should do it

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

You shoud store your polynomial of degree n in an (n+1) 'array' and using Jquery each method

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

Edit : if you don't know about jquery, you can use pure javascript for loop, for (var i = 0; i < myArray.length; i++) {...}



来源:https://stackoverflow.com/questions/14927494/how-to-create-a-calculus-derivative-solver-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!