
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (fma 4.0 (+ 0.75 (/ (- x z) y)) 1.0))
double code(double x, double y, double z) {
return fma(4.0, (0.75 + ((x - z) / y)), 1.0);
}
function code(x, y, z) return fma(4.0, Float64(0.75 + Float64(Float64(x - z) / y)), 1.0) end
code[x_, y_, z_] := N[(4.0 * N[(0.75 + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (* -4.0 (/ z y))))
(if (<= x -4.5e-5)
t_0
(if (<= x -6.2e-160)
t_1
(if (<= x -1.05e-199)
4.0
(if (<= x 6e-242)
t_1
(if (<= x 7.8e-174) 4.0 (if (<= x 8.5e-17) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = -4.0 * (z / y);
double tmp;
if (x <= -4.5e-5) {
tmp = t_0;
} else if (x <= -6.2e-160) {
tmp = t_1;
} else if (x <= -1.05e-199) {
tmp = 4.0;
} else if (x <= 6e-242) {
tmp = t_1;
} else if (x <= 7.8e-174) {
tmp = 4.0;
} else if (x <= 8.5e-17) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / y)
t_1 = (-4.0d0) * (z / y)
if (x <= (-4.5d-5)) then
tmp = t_0
else if (x <= (-6.2d-160)) then
tmp = t_1
else if (x <= (-1.05d-199)) then
tmp = 4.0d0
else if (x <= 6d-242) then
tmp = t_1
else if (x <= 7.8d-174) then
tmp = 4.0d0
else if (x <= 8.5d-17) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = -4.0 * (z / y);
double tmp;
if (x <= -4.5e-5) {
tmp = t_0;
} else if (x <= -6.2e-160) {
tmp = t_1;
} else if (x <= -1.05e-199) {
tmp = 4.0;
} else if (x <= 6e-242) {
tmp = t_1;
} else if (x <= 7.8e-174) {
tmp = 4.0;
} else if (x <= 8.5e-17) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = -4.0 * (z / y) tmp = 0 if x <= -4.5e-5: tmp = t_0 elif x <= -6.2e-160: tmp = t_1 elif x <= -1.05e-199: tmp = 4.0 elif x <= 6e-242: tmp = t_1 elif x <= 7.8e-174: tmp = 4.0 elif x <= 8.5e-17: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) t_1 = Float64(-4.0 * Float64(z / y)) tmp = 0.0 if (x <= -4.5e-5) tmp = t_0; elseif (x <= -6.2e-160) tmp = t_1; elseif (x <= -1.05e-199) tmp = 4.0; elseif (x <= 6e-242) tmp = t_1; elseif (x <= 7.8e-174) tmp = 4.0; elseif (x <= 8.5e-17) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); t_1 = -4.0 * (z / y); tmp = 0.0; if (x <= -4.5e-5) tmp = t_0; elseif (x <= -6.2e-160) tmp = t_1; elseif (x <= -1.05e-199) tmp = 4.0; elseif (x <= 6e-242) tmp = t_1; elseif (x <= 7.8e-174) tmp = 4.0; elseif (x <= 8.5e-17) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.5e-5], t$95$0, If[LessEqual[x, -6.2e-160], t$95$1, If[LessEqual[x, -1.05e-199], 4.0, If[LessEqual[x, 6e-242], t$95$1, If[LessEqual[x, 7.8e-174], 4.0, If[LessEqual[x, 8.5e-17], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{-199}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-242}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-174}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.50000000000000028e-5 or 8.5e-17 < x Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in x around inf 57.5%
if -4.50000000000000028e-5 < x < -6.2000000000000001e-160 or -1.05000000000000001e-199 < x < 6e-242 or 7.7999999999999997e-174 < x < 8.5e-17Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in z around inf 62.7%
if -6.2000000000000001e-160 < x < -1.05000000000000001e-199 or 6e-242 < x < 7.7999999999999997e-174Initial program 99.9%
Taylor expanded in y around inf 82.4%
Final simplification61.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.1e-32) (not (<= y 6.5e+18))) (+ 4.0 (/ (* z -4.0) y)) (+ 1.0 (* (- x z) (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e-32) || !(y <= 6.5e+18)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 1.0 + ((x - z) * (4.0 / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-3.1d-32)) .or. (.not. (y <= 6.5d+18))) then
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 1.0d0 + ((x - z) * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e-32) || !(y <= 6.5e+18)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 1.0 + ((x - z) * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.1e-32) or not (y <= 6.5e+18): tmp = 4.0 + ((z * -4.0) / y) else: tmp = 1.0 + ((x - z) * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.1e-32) || !(y <= 6.5e+18)) tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(1.0 + Float64(Float64(x - z) * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.1e-32) || ~((y <= 6.5e+18))) tmp = 4.0 + ((z * -4.0) / y); else tmp = 1.0 + ((x - z) * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.1e-32], N[Not[LessEqual[y, 6.5e+18]], $MachinePrecision]], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{-32} \lor \neg \left(y \leq 6.5 \cdot 10^{+18}\right):\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -3.10000000000000011e-32 or 6.5e18 < y Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 84.4%
sub-neg84.4%
distribute-lft-in84.4%
metadata-eval84.4%
associate-+r+84.4%
metadata-eval84.4%
neg-mul-184.4%
associate-*r*84.4%
metadata-eval84.4%
*-commutative84.4%
associate-*l/84.4%
Simplified84.4%
if -3.10000000000000011e-32 < y < 6.5e18Initial program 100.0%
Taylor expanded in y around 0 94.1%
*-lft-identity94.1%
associate-*l/93.8%
associate-*r*93.8%
associate-*r/93.8%
metadata-eval93.8%
Simplified93.8%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.2e+79) (not (<= z 2.9e+47))) (* (- x z) (/ 4.0 y)) (+ 4.0 (/ (* 4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.2e+79) || !(z <= 2.9e+47)) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0 + ((4.0 * x) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-8.2d+79)) .or. (.not. (z <= 2.9d+47))) then
tmp = (x - z) * (4.0d0 / y)
else
tmp = 4.0d0 + ((4.0d0 * x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8.2e+79) || !(z <= 2.9e+47)) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0 + ((4.0 * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.2e+79) or not (z <= 2.9e+47): tmp = (x - z) * (4.0 / y) else: tmp = 4.0 + ((4.0 * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.2e+79) || !(z <= 2.9e+47)) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); else tmp = Float64(4.0 + Float64(Float64(4.0 * x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8.2e+79) || ~((z <= 2.9e+47))) tmp = (x - z) * (4.0 / y); else tmp = 4.0 + ((4.0 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.2e+79], N[Not[LessEqual[z, 2.9e+47]], $MachinePrecision]], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+79} \lor \neg \left(z \leq 2.9 \cdot 10^{+47}\right):\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\end{array}
\end{array}
if z < -8.2e79 or 2.8999999999999998e47 < z Initial program 99.9%
Taylor expanded in y around 0 99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in y around 0 86.5%
*-commutative86.5%
associate-*l/86.5%
associate-/l*86.2%
Simplified86.2%
if -8.2e79 < z < 2.8999999999999998e47Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 88.3%
distribute-lft-in88.3%
metadata-eval88.3%
associate-+r+88.3%
metadata-eval88.3%
*-commutative88.3%
associate-*l/88.3%
Simplified88.3%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.1e-32) (not (<= y 37000.0))) (+ 4.0 (/ (* z -4.0) y)) (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e-32) || !(y <= 37000.0)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = (x - z) * (4.0 / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-3.1d-32)) .or. (.not. (y <= 37000.0d0))) then
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
else
tmp = (x - z) * (4.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e-32) || !(y <= 37000.0)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = (x - z) * (4.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.1e-32) or not (y <= 37000.0): tmp = 4.0 + ((z * -4.0) / y) else: tmp = (x - z) * (4.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.1e-32) || !(y <= 37000.0)) tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(Float64(x - z) * Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.1e-32) || ~((y <= 37000.0))) tmp = 4.0 + ((z * -4.0) / y); else tmp = (x - z) * (4.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.1e-32], N[Not[LessEqual[y, 37000.0]], $MachinePrecision]], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{-32} \lor \neg \left(y \leq 37000\right):\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -3.10000000000000011e-32 or 37000 < y Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 83.6%
sub-neg83.6%
distribute-lft-in83.6%
metadata-eval83.6%
associate-+r+83.6%
metadata-eval83.6%
neg-mul-183.6%
associate-*r*83.6%
metadata-eval83.6%
*-commutative83.6%
associate-*l/83.6%
Simplified83.6%
if -3.10000000000000011e-32 < y < 37000Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in y around 0 94.4%
*-commutative94.4%
associate-*l/94.4%
associate-/l*94.1%
Simplified94.1%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (<= y -8.2e+91) 4.0 (if (<= y 4.9e+179) (* (- x z) (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+91) {
tmp = 4.0;
} else if (y <= 4.9e+179) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-8.2d+91)) then
tmp = 4.0d0
else if (y <= 4.9d+179) then
tmp = (x - z) * (4.0d0 / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+91) {
tmp = 4.0;
} else if (y <= 4.9e+179) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e+91: tmp = 4.0 elif y <= 4.9e+179: tmp = (x - z) * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e+91) tmp = 4.0; elseif (y <= 4.9e+179) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e+91) tmp = 4.0; elseif (y <= 4.9e+179) tmp = (x - z) * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e+91], 4.0, If[LessEqual[y, 4.9e+179], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+91}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 4.9 \cdot 10^{+179}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -8.2000000000000005e91 or 4.8999999999999999e179 < y Initial program 99.9%
Taylor expanded in y around inf 73.4%
if -8.2000000000000005e91 < y < 4.8999999999999999e179Initial program 100.0%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in y around 0 83.9%
*-commutative83.9%
associate-*l/83.9%
associate-/l*83.7%
Simplified83.7%
Final simplification81.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.25e+54) (not (<= z 2.6e+48))) (* -4.0 (/ z y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.25e+54) || !(z <= 2.6e+48)) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.25d+54)) .or. (.not. (z <= 2.6d+48))) then
tmp = (-4.0d0) * (z / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.25e+54) || !(z <= 2.6e+48)) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.25e+54) or not (z <= 2.6e+48): tmp = -4.0 * (z / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.25e+54) || !(z <= 2.6e+48)) tmp = Float64(-4.0 * Float64(z / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.25e+54) || ~((z <= 2.6e+48))) tmp = -4.0 * (z / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.25e+54], N[Not[LessEqual[z, 2.6e+48]], $MachinePrecision]], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+54} \lor \neg \left(z \leq 2.6 \cdot 10^{+48}\right):\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if z < -1.25000000000000001e54 or 2.59999999999999995e48 < z Initial program 99.9%
Taylor expanded in y around 0 99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in z around inf 71.1%
if -1.25000000000000001e54 < z < 2.59999999999999995e48Initial program 99.9%
Taylor expanded in y around inf 43.7%
Final simplification55.4%
(FPCore (x y z) :precision binary64 (/ (* 4.0 (+ (- x z) y)) y))
double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - z) + y)) / y
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / y;
}
def code(x, y, z): return (4.0 * ((x - z) + y)) / y
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - z) + y)) / y) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - z) + y)) / y; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - z\right) + y\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 31.4%
Final simplification31.4%
herbie shell --seed 2024096
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))