In a question I want to catch the error that a sysmbolic result(thus no units, just variables) is of wrong physical dimension.
The correct answer looks like this: 64/3*a^3*t with a and t being of dimension length. Thus I want to test the input for the degree in length dimension.
My first idea was to check if degree(ans,a)+degree(ans,t) = 4
but this fails with this answer:
256*a^2*t/(12*(a-t))
the test gives degree(ans,a)+degree(ans,t) =3. but clearly the expression is of degree 2 in length.
so the next try is to use
dimtest(f):= degree(ev(f,t=rand(1.0)*a),a);
which would fail if by chance a difference of t and a would be zero.
Thus I don't feel safe. Any general solution for checking physical dimensions of expressions?