double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+56) {
tmp = y * -x;
} else if (z <= 2.2e+33) {
tmp = x * ((z * y) / sqrt(((z * z) - (t * a))));
} else {
tmp = y * x;
}
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) :: tmp
if (z <= (-1.9d+56)) then
tmp = y * -x
else if (z <= 2.2d+33) then
tmp = x * ((z * y) / sqrt(((z * z) - (t * a))))
else
tmp = y * x
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 tmp;
if (z <= -1.9e+56) {
tmp = y * -x;
} else if (z <= 2.2e+33) {
tmp = x * ((z * y) / Math.sqrt(((z * z) - (t * a))));
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a):
tmp = 0
if z <= -1.9e+56:
tmp = y * -x
elif z <= 2.2e+33:
tmp = x * ((z * y) / math.sqrt(((z * z) - (t * a))))
else:
tmp = y * x
return tmp
function code(x, y, z, t, a)
return Float64(Float64(Float64(x * y) * z) / sqrt(Float64(Float64(z * z) - Float64(t * a))))
end
↓
function code(x, y, z, t, a)
tmp = 0.0
if (z <= -1.9e+56)
tmp = Float64(y * Float64(-x));
elseif (z <= 2.2e+33)
tmp = Float64(x * Float64(Float64(z * y) / sqrt(Float64(Float64(z * z) - Float64(t * a)))));
else
tmp = Float64(y * x);
end
return tmp
end
function tmp = code(x, y, z, t, a)
tmp = ((x * y) * z) / sqrt(((z * z) - (t * a)));
end
↓
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (z <= -1.9e+56)
tmp = y * -x;
elseif (z <= 2.2e+33)
tmp = x * ((z * y) / sqrt(((z * z) - (t * a))));
else
tmp = y * x;
end
tmp_2 = tmp;
end
(*.f64 y (neg.f64 x)): 0 points increase in error, 0 points decrease in error
(Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y x))): 0 points increase in error, 0 points decrease in error
(Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 y x))): 0 points increase in error, 0 points decrease in error
if -1.89999999999999998e56 < z < 2.19999999999999994e33
Initial program 11.3
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\]
Simplified11.0
\[\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))))): 40 points increase in error, 13 points decrease in error
(/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a)))): 8 points increase in error, 35 points decrease in error
if 2.19999999999999994e33 < z
Initial program 35.6
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\]
Simplified35.5
\[\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))))): 40 points increase in error, 13 points decrease in error
(/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x y) z)) (sqrt.f64 (-.f64 (*.f64 z z) (*.f64 t a)))): 8 points increase in error, 35 points decrease in error
herbie shell --seed 2022316
(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)))))