问题描述
我正在开发简单的 js 神经网络,需要在学习开始之前创建 javascript 函数(用户输入的派生类)。
我知道evaluate(),但我认为它比简单的函数要慢。
这就是我想要的:
const derivative = math.derivative('x^2/sin(2x)','x');
const derivative_func = derivative.please_stay_func();
...
while(1) alert(derivate_func(12)) //:) alert result of (2 * 12 * Math.sin(2*12) - 2 * Math.pow(12,2) * Math.cos(2*12)) / Math.pow(sin(2*12),2)
是真的吗?也许我对速度的看法不对。也许有一些更好的方法 - 写在这里。
解决方法
我在手机上,请编辑此
也许这是你想做的
const countThings = (customValue) ==>{
let x = 'x^2/sin(x)';
let y = 'x';
x = math.parse(x)
y = math.parse(y)
return math.derivative(x,y).evaluate({x:customValue});}
console.log(countThings(12))
不要做 while(1) 提醒,因为它会一直提醒