We wrote a problem and set the tolerance for the answer checking as
Context("Complex");
Context()->flags->set(
tolerance => 0.01,
tolType => "absolute",
);
Context()->flags->set(
tolerance => 0.01,
tolType => "absolute",
);
in determining the angle of a complex number, we wanted to set the answer equal to zero if the magnitude was zero - of close enough to zero. So we had a test
if ($magnitude_A < 0.001) {
$angle_A = Real(0);
}
$angle_A = Real(0);
}
In my experiments, I seem to have found that if $magnitude_A = 0 (or 10^-14), the test fails and I get a somewhat random angle, not zero. If I change the test to $magnitude_A < 0.1 the test works and I get $angle_A = 0; or If keep the test at $magnitude_A < 0.001 and change the tolerance to tolerance => 0.0001, the test works.
I thought the tolerance was only on the answers, but it appears to be on all logical tests. Is this correct?
is the only way to guard against this by setting the answer tolerance in the checking statement, e.g.,
ANS($magnitude_A->cmp(tolerance => 0.01,tolType => "absolute"));
Thanks