Looking for derivative script

后端 未结 6 615
情话喂你
情话喂你 2021-01-05 20:20

I am desperately looking for a JavaScript that can calculate the first derivative of a function. The function always includes only one variable, x.



        
6条回答
  •  孤城傲影
    2021-01-05 21:06

    Try nerdamer .

    It can do derivatives and build JavaScript functions with it.

    //Derivative of x^2
    var result = nerdamer('diff(x^2,x)').evaluate();
    document.getElementById('text').innerHTML = "

    f'(x)="+result.text()+'

    '; //Build a new function var f = result.buildFunction(); //Evalute f'(3) document.getElementById('text').innerHTML += "

    f'(3)="+f(3).toString()+'

    ';
    
    
    
    
    

提交回复
热议问题