I’m writing a program that involves the Baker-Campbell-Hausdorff series. Suppose that I want to evaluate expressions with multiple nested commutators. (My actual application involves multiple nested Poisson brackets of 1D arrays, but it’s the same idea.) Suppose I’ve written a function cmt(a,b) that takes two matrices as input and returns their commutator,
cmt(a,b) = matmul(a,b) - matmul(b,a)
I need to evaluate very long expressions produced by Mathematica that look like,
e=cmt(a,b) + cmt(a,cmt(b,c))/3. - cmt(cmt(a,b),cmt(c,d))/10.
Is this acceptable in Fortran? gfortran doesn’t complain, but I’m getting strange results. I’m not sure if I’ve made a coding error or if this is non-standard Fortran. Is it legitimate for the actual argument in a function call (i.e., a user-supplied function, not an intrinsic) to contain the same function name?