BendMlAutograd.nfwd: def of bend-ml-autograd@0.1.1.0 Import: import bend-ml-autograd@0.1.1.0/main.bend as BendMlAutograd Lines 41-51 of bend-ml-autograd@0.1.1.0/main.bend: https://jend.leeeet.dev/read.txt?path=bend-ml-autograd@0.1.1.0/main.bend&start_line=41&end_line=51 import Base # FORWARD-mode derivative (dual numbers): derivative of the sum and the product rule def nfwd(e: NE, +x: Nat) -> Nat: match e: case NCst{n}: 0n case NX{}: 1n case NAdd{a, b}: Nat.add(nfwd(a, x), nfwd(b, x)) case NMul{+a, +b}: Nat.add(Nat.mul(nfwd(a, x), nval(b, x)), Nat.mul(nval(a, x), nfwd(b, x))) Uses (5): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=bend-ml-autograd@0.1.1.0/main.bend&name=NE https://jend.leeeet.dev/definition.txt?path=bend-ml-autograd@0.1.1.0/main.bend&name=nval