Dear Prof van Zon,
In assignment 9, "analyzewave.cpp", lines 90 and 91
'''
// compute energies
double T = 0.0;
double V = 0.0;
for (int i=1; i<nrows-1; i++) { \\line 90
for (int j=1; j<ncols-1; j++) { \\line 91
T += pow((dx/outtime)*(rho[i][j]-rho_prev[i][j]),2);
V += pow(c,2)*(pow(rho[i][j]-rho[i-1][j],2)
+pow(rho[i][j]-rho[i][j-1],2));
}
}
'''
I suspect that they should be
'''
for (int i=1; i<nrows; i++) { \\line 90
for (int j=1; j<ncols; j++) { \\line 91
'''
Or are the potential energy (V) between the last two lines and the last two columns not calculated? But I am not sure whether I made another wrong mathematical statement...