Just so you know, it is possible to write $P^T A P = D$ diagonal with the entries of $P$ being rational expressions in the entries of $A.$ If desired, we can take a diagonal matrix $Q$ involving square roots of the absolute values of the entries of $D$ to get $Q P^T A P Q = W,$ where $W$ is diagonal and all entries are $0,1,-1.$ Note that there is no need for $A$ to be positive, just symmetric.
Here is the idea in symbols; one may change the order of operations if convenient.
? m = [ a,f,e; f,b,d; e,d,c]
%1 =
[a f e]
[f b d]
[e d c]
? m - mattranspose(m)
%2 =
[0 0 0]
[0 0 0]
[0 0 0]
? p1 = [ 1, -f/a, -e/a; 0,1,0; 0,0,1]
%6 =
[1 -f/a -e/a]
[0 1 0]
[0 0 1]
? m1 = mattranspose(p1) * m * p1
%7 =
[a 0 0]
[0 (b*a - f^2)/a (d*a - e*f)/a]
[0 (d*a - e*f)/a (c*a - e^2)/a]
? p2 = [ 1,0,0; 0,1, (a * d - e * f) / (f^2 - a * b); 0,0,1]
%9 =
[1 0 0]
[0 1 (d*a - e*f)/(-b*a + f^2)]
[0 0 1]
? m2 = mattranspose(p2) * m1 * p2
%10 =
[a 0 0]
[0 (b*a - f^2)/a 0]
[0 0 ((-c*b + d^2)*a + (c*f^2 - 2*d*e*f + b*e^2))/(-b*a + f^2)]
? m
%11 =
[a f e]
[f b d]
[e d c]
? matdet(m)
%12 = (c*b - d^2)*a + (-c*f^2 + 2*d*e*f - b*e^2)
?