Derivatives in C/C++?

I have some expressions such as `x^2+y^2` that I'd like to use for some math calculations. One of the things I'd like to do is to take partial derivatives of the expressions. So if `f(x,y) = x^2 + y^2` then the partial of `f` with respect to `x` would be `2x`, the partial with respect to `y` would be `2y`. I wrote a dinky function using a finite differences method but I'm running into lots of problems with floating point precision. For example, I end up with `1.99234` instead of `2`. Are there any libraries that support symbolic differentiation? Any other suggestions?
Rolling your own would be a bad idea. I've taken a cross-listed grad course in Computer Algebra, and things are not even quite feature complete. Simplistic differentiation could be done by applying maty rules and then try to substitute and evaluate... hard to do in C/C++.

以上就是Derivatives in C/C++?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准