set title "Increasing polynomial order decreases inaccuracy in filter gain at ideal -3dB frequency" set xlabel "Frequency (fraction of sample rate)" set ylabel "Inaccuracy (bits)" set term pngcairo dashed enhanced font 'LMSans10' size 1280,720 set output 'x.png' set samples 2000 set log x 2 set grid set xtics 0.5 set ytics 6 set format x "%.2e" set key horizontal f9(x) = a9 * (x - 0.25) + b9 * (x - 0.25)**3 + c9 * (x - 0.25)**5 + d9 * (x - 0.25)**7 + e9 * (x - 0.25)**9 fit f9(x) 'x.dat' via a9,b9,c9,d9,e9 f7(x) = a7 * (x - 0.25) + b7 * (x - 0.25)**3 + c7 * (x - 0.25)**5 + d7 * (x - 0.25)**7 fit f7(x) 'x.dat' via a7,b7,c7,d7 f5(x) = a5 * (x - 0.25) + b5 * (x - 0.25)**3 + c5 * (x - 0.25)**5 fit f5(x) 'x.dat' via a5,b5,c5 f3(x) = a3 * (x - 0.25) + b3 * (x - 0.25)**3 fit f3(x) 'x.dat' via a3,b3 f1(x) = a1 * (x - 0.25) fit f1(x) 'x.dat' via a1 g(x) = (1 - sin(2 * pi * x)) / cos(2 * pi * x) G(x,y) = 10 * log( (1 - y)**2/4 * 2 * (1 + cos(2 * pi * x)) / (1 - 2 * y * cos(2 * pi* x) + y*y) ) / log(10) B(x,y) = log(abs(G(x,y) / (10 * log(0.5) / log(10)) - 1))/log(2) plot [0.5**12:0.5][-60:12] B(x,g(x)) title 'trigonometric' lc 0, B(x,f1(x)) title '1-polynomial' lt 1, B(x,f3(x)) title '3-polynomial' lt 2, B(x,f5(x)) title '5-polynomial' lt 3, B(x,f7(x)) title '7-polynomial' lt 4, B(x,f9(x)) title '9-polynomial' lt 5, -53 title "double precision", -24 title "single precision" lc 0