自动分化 [英] Automatic differentiation
问题描述
f 1 (x 1 ,x 2 , x 3 ,...,x 12 )= 0
f 2 (x 1 >,x 2 ,x 3 ,...,x 12 )= 0
。
。
。
f 12 (x 1 ,x 2 ,x 3 ,..., x 12 )= 0
其中x 1 ,x 2 ,x 3 是变量(温度,压力...等)
我可以自动执行此操作吗?如果在Fortran中不可行,我可以使用其他脚本语言作为Python(sympy模块)吗? 解决方案
是的,通过使用一个适当的算法差异化包。这是一种可以评估(原则上)任意函数派生程序的方法,您可以使用计算机程序来表示任何函数的派生程序,并且Fortran中有许多软件包。看看
http:// en。 wikipedia.org/wiki/Automatic_differentiation
和
http://www.nag.co.uk/pss/nag-and-algorithmic-differentiation
开始使用
免责声明:
1)我从来没有在愤怒中使用过它。2)直到最近我还为NAG工作过。
I am working on my project of graduating, particularly, about fluid dynamics and I have a system of non-linear equations to solve, I choose the Newton's method so I have to pass through the Jacobian of the matix (actually 12x12 matrix). Every element in this matrix is the derivative of the function evaluated at some point, it's very difficult to write all of these manually and calculate each derivative; the system looks like:
f1 (x1, x2, x3, ..., x12) = 0f2 (x1, x2, x3, ..., x12) = 0
.
.
.
f12 (x1, x2, x3, ..., x12) = 0
Where x1, x2, x3 are the variables (Temperature, pressure ...etc)
Can I automate this operation? If it's not possible in Fortran, can I use other scripting languages as Python (sympy module)?
Yes, by use of an appropriate algorithmic differentiation package. This is a method which can evaluate (in principle) arbitrary order derivatives of any function you have expressed as a computer program, and a number of packages exist for Fortran. Take a look at
http://en.wikipedia.org/wiki/Automatic_differentiation
and
http://www.nag.co.uk/pss/nag-and-algorithmic-differentiation
to get started
Disclaimers:
1) I have never used it "in anger"
2) Until recently I worked for NAG
这篇关于自动分化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!