<divclass="content sourceset-depenent-content"data-active=""data-togglable=":kmath-core:dokkaHtmlPartial/commonMain"><divclass="symbol monospace"><spanclass="token keyword"></span><spanclass="token keyword">fun </span><spanclass="token operator"><</span><spanclass="token keyword"></span><ahref="derive.html">R</a><spanclass="token operator">></span><ahref="derive.html"><spanclass="token function">derive</span></a><spanclass="token punctuation">(</span>value<spanclass="token operator">: </span><ahref="derive.html">R</a><spanclass="token punctuation">, </span>block<spanclass="token operator">: </span><spanclass="token keyword"></span><ahref="index.html">F</a><spanclass="token punctuation">.</span><spanclass="token punctuation">(</span><spanclass="token keyword"></span><ahref="derive.html">R</a><spanclass="token punctuation">)</span><spanclass="token operator"> -></span><spanclass="token keyword"></span><ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a><spanclass="token punctuation">)</span><spanclass="token operator">: </span><ahref="derive.html">R</a><spanclass="top-right-position"><spanclass="copy-icon"></span><divclass="copy-popup-wrapper popup-to-left"><spanclass="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><pclass="paragraph">Performs update of derivative after the rest of the formula in the back-pass.</p><pclass="paragraph">For example, implementation of <codeclass="lang-kotlin">sin</code> function is:</p><divclass="sample-container"><pre><codeclass="block lang-kotlin"theme="idea">fun AD.sin(x: Variable): Variable = derive(Variable(sin(x.x)) { z -> // call derive with function result<br> x.d += z.d * cos(x.x) // update derivative using chain rule and derivative of the function<br>}</code></pre><spanclass="top-right-position"><spanclass="copy-icon"></span><divclass="copy-popup-wrapper popup-to-left"><spanclass="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div></div></div>