(FPCore (x y z t a)
:precision binary64
(/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
↓
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* z (pow (- (* z z) (* a t)) -0.5))))
(if (<= z -5.864915385361467e+154)
(* (/ 1.0 (/ (- (/ a (/ z (* t 0.5))) z) z)) (* x y))
(if (<= z -1e-180)
(* x (* y t_1))
(if (<= z 1e-160)
(* z (* (* (pow (- t) -0.5) (pow a -0.5)) (* x y)))
(if (<= z 1.5551926624209129e+156) (* t_1 (* x y)) (* x y)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = z * pow(((z * z) - (a * t)), -0.5);
double tmp;
if (z <= -5.864915385361467e+154) {
tmp = (1.0 / (((a / (z / (t * 0.5))) - z) / z)) * (x * y);
} else if (z <= -1e-180) {
tmp = x * (y * t_1);
} else if (z <= 1e-160) {
tmp = z * ((pow(-t, -0.5) * pow(a, -0.5)) * (x * y));
} else if (z <= 1.5551926624209129e+156) {
tmp = t_1 * (x * y);
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) * z) / sqrt(((z * z) - (t * a)))
end function
↓
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = z * (((z * z) - (a * t)) ** (-0.5d0))
if (z <= (-5.864915385361467d+154)) then
tmp = (1.0d0 / (((a / (z / (t * 0.5d0))) - z) / z)) * (x * y)
else if (z <= (-1d-180)) then
tmp = x * (y * t_1)
else if (z <= 1d-160) then
tmp = z * (((-t ** (-0.5d0)) * (a ** (-0.5d0))) * (x * y))
else if (z <= 1.5551926624209129d+156) then
tmp = t_1 * (x * y)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) * z) / Math.sqrt(((z * z) - (t * a)));
}
↓
public static double code(double x, double y, double z, double t, double a) {
double t_1 = z * Math.pow(((z * z) - (a * t)), -0.5);
double tmp;
if (z <= -5.864915385361467e+154) {
tmp = (1.0 / (((a / (z / (t * 0.5))) - z) / z)) * (x * y);
} else if (z <= -1e-180) {
tmp = x * (y * t_1);
} else if (z <= 1e-160) {
tmp = z * ((Math.pow(-t, -0.5) * Math.pow(a, -0.5)) * (x * y));
} else if (z <= 1.5551926624209129e+156) {
tmp = t_1 * (x * y);
} else {
tmp = x * y;
}
return tmp;
}
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\]
Simplified8.8
\[\leadsto \color{blue}{x \cdot \frac{y \cdot z}{\sqrt{z \cdot z - t \cdot a}}}
\]
Proof
(*.f64 x (/.f64 (*.f64 y z) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 0 points increase in error, 0 points decrease in error
(Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x (*.f64 y z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 49 points increase in error, 8 points decrease in error
(/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a)))): 6 points increase in error, 46 points decrease in error
Applied egg-rr4.8
\[\leadsto x \cdot \color{blue}{\left(y \cdot \left(z \cdot {\left(z \cdot z - t \cdot a\right)}^{-0.5}\right)\right)}
\]
if -1e-180 < z < 9.9999999999999999e-161
Initial program 18.2
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\]
Applied egg-rr18.4
\[\leadsto \color{blue}{z \cdot \left(\left(x \cdot y\right) \cdot {\left(z \cdot z - t \cdot a\right)}^{-0.5}\right)}
\]
if 9.9999999999999999e-161 < z < 1.5551926624209129e156
Initial program 9.2
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\]
Applied egg-rr5.6
\[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \left(z \cdot {\left(z \cdot z - t \cdot a\right)}^{-0.5}\right)}
\]
if 1.5551926624209129e156 < z
Initial program 54.3
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\]
Simplified54.4
\[\leadsto \color{blue}{x \cdot \frac{y \cdot z}{\sqrt{z \cdot z - t \cdot a}}}
\]
Proof
(*.f64 x (/.f64 (*.f64 y z) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 0 points increase in error, 0 points decrease in error
(Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x (*.f64 y z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a))))): 49 points increase in error, 8 points decrease in error
(/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a)))): 6 points increase in error, 46 points decrease in error
herbie shell --seed 2022317
(FPCore (x y z t a)
:name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))
(/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))