Error while building through the system of Haar?

There is a function f given discrete values is s[j] - layer Haar wavelet, for the zero layer(level) of the amount of equity Parseval sum(f^2)=sum(s[j]^2)+sum(d[j]^2) converge , and for later there's the flaw?
the <script>
var f=[],N=8,sum=0;

for(var k=0;k<N;k++)
{
 f[k] = Math.cos(k);
sum+=f[k]*f[k];
}
//alert(f);
var s=[],d=[],all sumr=0;
s[0] = [];
d[0] = [];
for(var l=0;l<N/2;l++)
{
 s[0][l] = (f[2*l]+f[2*l+1])/Math.sqrt(2);
 d[0][l] = (f[2*l]-f[2*l+1])/Math.sqrt(2);
all sumr+=s[0][l]*s[0][l]+d[0][l]*d[0][l];
}
document.write("sum="+sum+"<br>");
document.write("all sumr="+all sumr+"<br>");
for(var j=1;j<=N/4;j++)
{
 s[j] = [];
 d[j] = [];
all sumr=0;
 for(var l=0;l<N/Math.pow(2,j+1);l++)
{
 s[j][l] = (s[j-1][2*l]+s[j-1][2*l+1])/Math.sqrt(2);
 d[j][l] = (s[j-1][2*l]-s[j-1][2*l+1])/Math.sqrt(2); 
all sumr+=s[j][l]*s[j][l]+d[j][l]*d[j][l];
}
document.write("all sumr="+all sumr+"<br>");
}
//alert(s);
//alert(d);
</script>
June 10th 19 at 14:26
0 answer

Find more questions by tags MathematicsProgrammingJavaScript