Automatic differentiation using dual numbers
|
06-19-2022, 02:40 PM
(This post was last modified: 07-11-2022 05:28 PM by Albert Chan.)
Post: #13
|
|||
|
|||
RE: Automatic differentiation using dual numbers
(06-18-2022 02:09 PM)Thomas Klemm Wrote: Find a root of : \(x^x = \pi\) Removing constant exponent limitation is not hard. r = f^g r' = (exp(ln(f)*g))' = r * (ln(f)*g)' = r * (ln(f)*g' + (f'/f)*g) Code: function D.__pow(f,g) We add above pow rule here lua> x = D.new(2,1) lua> for k=1,6 do print(D.newton(x, x^x - D.new(pi))) end 1.8732526982494337 0.8584073464102069 1.8544597179031999 0.09913010983767823 1.8541060899613326 0.001798101943065511 1.854105967921041 6.201137425776437e-007 1.8541059679210263 7.416289804496046e-014 1.8541059679210263 -4.440892098500626e-016 Note: outputs are (extrapolated x, f(x)); Shift up 2nd column to get points (x, f(x)) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)