CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Nonlinear solver & Differentiation Chain Rule (https://www.cfd-online.com/Forums/main/16313-nonlinear-solver-differentiation-chain-rule.html)

Frank February 5, 2009 06:36

Nonlinear solver & Differentiation Chain Rule
 
I am trying to solve a horrible function using newtons method and need to differentiate it. There is only one unknown variable x.

The problem is that the function I am looking at is a function of a function of a function... very nonlinear and nasty. I don't have access to my elementary textbooks from work and am pretty rusty when it comes to differentiation.

Am I right in thinking that I can repeatedly apply the chain rule, e.g

du/dx = du/da * da/db * db/dx

I'm pretty sure this is right but wanted to make sure before I start sticking coefficients in the software.


Farid February 5, 2009 07:42

Re: Nonlinear solver & Differentiation Chain Rule
 
Yes of course!You have to use the chain rule until the expression is easy enough to compute db/dx. If it's a really nasty expression, I would suggest you to do it with Matlab! Otherwise you might make a mistake by solving it by hand.

syms x; (new line) y = nasty espression; (new line) diff(y,x)

That's it Cheers Farid

Praveen. C February 6, 2009 02:17

Re: Nonlinear solver & Differentiation Chain Rule
 
If you have a computer program that is computing these functions, then you can use automatic differentiation. No pain in this. See http://www.autodiff.org

There are AD tools for fortran, C and even matlab.


All times are GMT -4. The time now is 16:32.