J, 110 104 95 8979 bytes, OO(nn log nn)
f=:_2&([:0((+,-)(%_1^i]%_1^i.@#%#))&f/@|:_2]\])^:(1<#]\)~1<#
9:o.<:@+&#{.[:@+&#$9(o.f%#)[:+@*/,:f@;f@{."1~2^#@#&>~2^#@#:@+&#
f =: _2&([:0((+,-)(%_1^i]%_1^i.@#%#))&f/@|:_2]\])^:(1<#]\)~1<#
g =: 9:o.<:@+&#{.[:@+&#$9(o.f%#)[:+@*/,:f@;f@{."1~2^#@#&>~2^#@#:@+&#
1 2 3 4 g 5 6 7 8
5 16 34 60 61 52 32
2 4 5 6 1 g 1 2 4 7
2 8 21 46 61 61 46 7
Try it online!
Explanation (Outdated)
9 o.<:@+&#{.[:@+&#$9(o.f%#)[:+@*/,:f@;f@{."1~2^2>.@^.+&#&>~2^#@#:@+&# Input: A on LHS, B on RHS
# Get the lengths of A and B
+& Sum them
2 ^. #:@ Find log baseGet 2list of it
binary digits
>.@ #@ Find its ceilingLength
2^ Raise 2 to that power, call it PN
,:; JoinLink A and B as separatea rows
pair of boxed arrays
{."1~&>~ PadFor each row with zeros to length Pbox
f@{. Take theN FFTvalues, ofextending eachwith rowzeros
[: */ f@ Multiply theApply rowsFFT togetherto elementwiseit
+@ [: */ Take the conjugate ofReduce eachusing valuemultiplication
[: f +@ Take the FFT of that listConjugate
# f Get the length of the list (equal toApply P)FFT
% Divide each by P
# # Get the lengths of A and BLength
+& 9 o. Take Sumthe themreal togetherpart
<:@ # Decrement it
Get the lengths of {.A and B
+& Take that many values from the previousSum listthem
9 o. <:@ Take the real part of each valueDecrement
$ Shape Returnto that list aslength theand resultreturn