
(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 10 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-sub100.0%
sub-neg100.0%
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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (* -4.0 (/ z y))))
(if (<= z -2.1e+63)
t_1
(if (<= z -1.45e-23)
4.0
(if (<= z -9e-201)
t_0
(if (<= z 8e-239) 4.0 (if (<= z 4.5e+40) t_0 t_1)))))))
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 (z <= -2.1e+63) {
tmp = t_1;
} else if (z <= -1.45e-23) {
tmp = 4.0;
} else if (z <= -9e-201) {
tmp = t_0;
} else if (z <= 8e-239) {
tmp = 4.0;
} else if (z <= 4.5e+40) {
tmp = t_0;
} else {
tmp = t_1;
}
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 (z <= (-2.1d+63)) then
tmp = t_1
else if (z <= (-1.45d-23)) then
tmp = 4.0d0
else if (z <= (-9d-201)) then
tmp = t_0
else if (z <= 8d-239) then
tmp = 4.0d0
else if (z <= 4.5d+40) then
tmp = t_0
else
tmp = t_1
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 (z <= -2.1e+63) {
tmp = t_1;
} else if (z <= -1.45e-23) {
tmp = 4.0;
} else if (z <= -9e-201) {
tmp = t_0;
} else if (z <= 8e-239) {
tmp = 4.0;
} else if (z <= 4.5e+40) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = -4.0 * (z / y) tmp = 0 if z <= -2.1e+63: tmp = t_1 elif z <= -1.45e-23: tmp = 4.0 elif z <= -9e-201: tmp = t_0 elif z <= 8e-239: tmp = 4.0 elif z <= 4.5e+40: tmp = t_0 else: tmp = t_1 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 (z <= -2.1e+63) tmp = t_1; elseif (z <= -1.45e-23) tmp = 4.0; elseif (z <= -9e-201) tmp = t_0; elseif (z <= 8e-239) tmp = 4.0; elseif (z <= 4.5e+40) tmp = t_0; else tmp = t_1; 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 (z <= -2.1e+63) tmp = t_1; elseif (z <= -1.45e-23) tmp = 4.0; elseif (z <= -9e-201) tmp = t_0; elseif (z <= 8e-239) tmp = 4.0; elseif (z <= 4.5e+40) tmp = t_0; else tmp = t_1; 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[z, -2.1e+63], t$95$1, If[LessEqual[z, -1.45e-23], 4.0, If[LessEqual[z, -9e-201], t$95$0, If[LessEqual[z, 8e-239], 4.0, If[LessEqual[z, 4.5e+40], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -2.1 \cdot 10^{+63}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.45 \cdot 10^{-23}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq -9 \cdot 10^{-201}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-239}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.1000000000000002e63 or 4.50000000000000032e40 < z Initial program 99.9%
Taylor expanded in z around inf 71.8%
*-commutative71.8%
Simplified71.8%
if -2.1000000000000002e63 < z < -1.4500000000000001e-23 or -9.0000000000000004e-201 < z < 8.0000000000000006e-239Initial program 99.9%
Taylor expanded in y around inf 67.2%
if -1.4500000000000001e-23 < z < -9.0000000000000004e-201 or 8.0000000000000006e-239 < z < 4.50000000000000032e40Initial program 99.9%
Taylor expanded in x around inf 54.4%
Final simplification64.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.05e+67) (not (<= z 1.3e+61))) (* 4.0 (/ (- x z) y)) (+ 4.0 (* x (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.05e+67) || !(z <= 1.3e+61)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (x * (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 ((z <= (-2.05d+67)) .or. (.not. (z <= 1.3d+61))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.05e+67) || !(z <= 1.3e+61)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.05e+67) or not (z <= 1.3e+61): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.05e+67) || !(z <= 1.3e+61)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.05e+67) || ~((z <= 1.3e+61))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.05e+67], N[Not[LessEqual[z, 1.3e+61]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+67} \lor \neg \left(z \leq 1.3 \cdot 10^{+61}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if z < -2.0499999999999999e67 or 1.29999999999999986e61 < z Initial program 99.9%
Taylor expanded in y around 0 87.4%
if -2.0499999999999999e67 < z < 1.29999999999999986e61Initial 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-sub100.0%
sub-neg100.0%
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 92.2%
distribute-lft-in92.2%
metadata-eval92.2%
associate-+r+92.2%
metadata-eval92.2%
associate-*r/92.2%
*-commutative92.2%
associate-*r/91.6%
Simplified91.6%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -6e+65) (not (<= z 1.7e+57))) (* 4.0 (/ (- x z) y)) (* (/ 4.0 y) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6e+65) || !(z <= 1.7e+57)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = (4.0 / y) * (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 <= (-6d+65)) .or. (.not. (z <= 1.7d+57))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = (4.0d0 / y) * (x + y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6e+65) || !(z <= 1.7e+57)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = (4.0 / y) * (x + y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6e+65) or not (z <= 1.7e+57): tmp = 4.0 * ((x - z) / y) else: tmp = (4.0 / y) * (x + y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6e+65) || !(z <= 1.7e+57)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(Float64(4.0 / y) * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6e+65) || ~((z <= 1.7e+57))) tmp = 4.0 * ((x - z) / y); else tmp = (4.0 / y) * (x + y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6e+65], N[Not[LessEqual[z, 1.7e+57]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 / y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+65} \lor \neg \left(z \leq 1.7 \cdot 10^{+57}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{4}{y} \cdot \left(x + y\right)\\
\end{array}
\end{array}
if z < -6.0000000000000004e65 or 1.69999999999999996e57 < z Initial program 99.9%
Taylor expanded in y around 0 87.4%
if -6.0000000000000004e65 < z < 1.69999999999999996e57Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in z around 0 92.2%
associate-*r/92.2%
+-commutative92.2%
*-commutative92.2%
associate-/l*91.5%
+-commutative91.5%
Simplified91.5%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.22e+64) (* 4.0 (/ (- x z) y)) (if (<= z 3.5e+40) (/ (* 4.0 (+ x y)) y) (+ 4.0 (* z (/ -4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.22e+64) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 3.5e+40) {
tmp = (4.0 * (x + y)) / y;
} else {
tmp = 4.0 + (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 (z <= (-1.22d+64)) then
tmp = 4.0d0 * ((x - z) / y)
else if (z <= 3.5d+40) then
tmp = (4.0d0 * (x + y)) / y
else
tmp = 4.0d0 + (z * ((-4.0d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.22e+64) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 3.5e+40) {
tmp = (4.0 * (x + y)) / y;
} else {
tmp = 4.0 + (z * (-4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.22e+64: tmp = 4.0 * ((x - z) / y) elif z <= 3.5e+40: tmp = (4.0 * (x + y)) / y else: tmp = 4.0 + (z * (-4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.22e+64) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); elseif (z <= 3.5e+40) tmp = Float64(Float64(4.0 * Float64(x + y)) / y); else tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.22e+64) tmp = 4.0 * ((x - z) / y); elseif (z <= 3.5e+40) tmp = (4.0 * (x + y)) / y; else tmp = 4.0 + (z * (-4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.22e+64], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.5e+40], N[(N[(4.0 * N[(x + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.22 \cdot 10^{+64}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+40}:\\
\;\;\;\;\frac{4 \cdot \left(x + y\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\end{array}
\end{array}
if z < -1.21999999999999994e64Initial program 99.9%
Taylor expanded in y around 0 86.0%
if -1.21999999999999994e64 < z < 3.4999999999999999e40Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in x around inf 92.1%
if 3.4999999999999999e40 < z Initial program 100.0%
+-commutative100.0%
associate-/l*100.0%
fma-define100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
associate--r+100.0%
div-sub100.0%
sub-neg100.0%
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 90.7%
sub-neg90.7%
distribute-lft-in90.7%
metadata-eval90.7%
associate-+r+90.7%
metadata-eval90.7%
neg-mul-190.7%
associate-*r*90.7%
metadata-eval90.7%
associate-*r/90.7%
*-commutative90.7%
associate-/l*90.5%
Simplified90.5%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.05e+65) (* 4.0 (/ (- x z) y)) (if (<= z 9.5e+32) (+ 4.0 (* x (/ 4.0 y))) (+ 4.0 (* z (/ -4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05e+65) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 9.5e+32) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 + (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 (z <= (-1.05d+65)) then
tmp = 4.0d0 * ((x - z) / y)
else if (z <= 9.5d+32) then
tmp = 4.0d0 + (x * (4.0d0 / y))
else
tmp = 4.0d0 + (z * ((-4.0d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.05e+65) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 9.5e+32) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 + (z * (-4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.05e+65: tmp = 4.0 * ((x - z) / y) elif z <= 9.5e+32: tmp = 4.0 + (x * (4.0 / y)) else: tmp = 4.0 + (z * (-4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.05e+65) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); elseif (z <= 9.5e+32) tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); else tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.05e+65) tmp = 4.0 * ((x - z) / y); elseif (z <= 9.5e+32) tmp = 4.0 + (x * (4.0 / y)); else tmp = 4.0 + (z * (-4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.05e+65], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.5e+32], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+65}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+32}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\end{array}
\end{array}
if z < -1.04999999999999996e65Initial program 99.9%
Taylor expanded in y around 0 86.0%
if -1.04999999999999996e65 < z < 9.50000000000000006e32Initial 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-sub100.0%
sub-neg100.0%
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 92.1%
distribute-lft-in92.1%
metadata-eval92.1%
associate-+r+92.1%
metadata-eval92.1%
associate-*r/92.1%
*-commutative92.1%
associate-*r/91.6%
Simplified91.6%
if 9.50000000000000006e32 < z Initial program 100.0%
+-commutative100.0%
associate-/l*100.0%
fma-define100.0%
associate--l+100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
associate--r+100.0%
div-sub100.0%
sub-neg100.0%
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 90.7%
sub-neg90.7%
distribute-lft-in90.7%
metadata-eval90.7%
associate-+r+90.7%
metadata-eval90.7%
neg-mul-190.7%
associate-*r*90.7%
metadata-eval90.7%
associate-*r/90.7%
*-commutative90.7%
associate-/l*90.5%
Simplified90.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.3e+135) 4.0 (if (<= y 1.7e+112) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.3e+135) {
tmp = 4.0;
} else if (y <= 1.7e+112) {
tmp = 4.0 * ((x - 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 (y <= (-1.3d+135)) then
tmp = 4.0d0
else if (y <= 1.7d+112) then
tmp = 4.0d0 * ((x - 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 (y <= -1.3e+135) {
tmp = 4.0;
} else if (y <= 1.7e+112) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.3e+135: tmp = 4.0 elif y <= 1.7e+112: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.3e+135) tmp = 4.0; elseif (y <= 1.7e+112) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.3e+135) tmp = 4.0; elseif (y <= 1.7e+112) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.3e+135], 4.0, If[LessEqual[y, 1.7e+112], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{+135}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+112}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.3e135 or 1.69999999999999997e112 < y Initial program 99.8%
Taylor expanded in y around inf 77.8%
if -1.3e135 < y < 1.69999999999999997e112Initial program 100.0%
Taylor expanded in y around 0 84.8%
(FPCore (x y z) :precision binary64 (if (<= y -4.2e-14) 4.0 (if (<= y 1.35e+88) (* 4.0 (/ x y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e-14) {
tmp = 4.0;
} else if (y <= 1.35e+88) {
tmp = 4.0 * (x / 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 <= (-4.2d-14)) then
tmp = 4.0d0
else if (y <= 1.35d+88) then
tmp = 4.0d0 * (x / 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 <= -4.2e-14) {
tmp = 4.0;
} else if (y <= 1.35e+88) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e-14: tmp = 4.0 elif y <= 1.35e+88: tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e-14) tmp = 4.0; elseif (y <= 1.35e+88) tmp = Float64(4.0 * Float64(x / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.2e-14) tmp = 4.0; elseif (y <= 1.35e+88) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e-14], 4.0, If[LessEqual[y, 1.35e+88], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-14}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+88}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -4.1999999999999998e-14 or 1.35000000000000008e88 < y Initial program 99.9%
Taylor expanded in y around inf 63.5%
if -4.1999999999999998e-14 < y < 1.35000000000000008e88Initial program 100.0%
Taylor expanded in x around inf 49.0%
(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 33.9%
herbie shell --seed 2024156
(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)))