A desk holds three assets and has estimated two of the three pairwise correlations: corr(1, 2) = a and corr(1, 3) = b. The third, corr(2, 3), has not been estimated yet.
Not every value in [-1, 1] is possible for it. Output the exact range of values corr(2, 3) can take.
You are given q such pairs (a, b); answer each.
The first line contains the integer q. Each of the next q lines contains a and b, each with at most 6 digits after the decimal point.
q lines. Line i contains two real numbers: the smallest and the largest feasible value of corr(2, 3) for pair i, each with absolute or relative error at most 1e-9.
1 <= q <= 1000
-1 < a, b < 1
This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.
Numeric answers are accepted if they are within an absolute tolerance of 1e-09 or a relative tolerance of 1e-09 of the expected value.
3 0.9 0.9 0 0 -0.8 0.6
0.62 1.0 -1.0 1.0 -0.96 0.0
1 0.5 0.5
-0.5 1.0