Automatic differentiation and Trapz

Hi Maxime :slight_smile: To complete the responses here, the issue is that Zygote does not support mutation of arrays (which is anyway a pretty tricky thing to do in an AD engine). You can just precompute weights and replace trapz(x) with sum(weights .* x): you’ll need to compute the weights if you want to write a rrule as @stevengj suggested anyway. Or just don’t use Trapz and use a simple uniform integration scheme.

1 Like