
(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 (+ 4.0 (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - 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 = 4.0d0 + (4.0d0 * ((x - z) / y))
end function
public static double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - z) / y));
}
def code(x, y, z): return 4.0 + (4.0 * ((x - z) / y))
function code(x, y, z) return Float64(4.0 + Float64(4.0 * Float64(Float64(x - z) / y))) end
function tmp = code(x, y, z) tmp = 4.0 + (4.0 * ((x - z) / y)); end
code[x_, y_, z_] := N[(4.0 + N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + 4 \cdot \frac{x - z}{y}
\end{array}
Initial program 100.0%
Taylor expanded in y around inf 100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (* -4.0 (/ z y))))
(if (<= x -4.5e+71)
t_0
(if (<= x -7.2e-167)
t_1
(if (<= x -1.25e-258)
4.0
(if (<= x 2.8e-291)
t_1
(if (<= x 4.1e-136) 4.0 (if (<= x 2e-26) 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+71) {
tmp = t_0;
} else if (x <= -7.2e-167) {
tmp = t_1;
} else if (x <= -1.25e-258) {
tmp = 4.0;
} else if (x <= 2.8e-291) {
tmp = t_1;
} else if (x <= 4.1e-136) {
tmp = 4.0;
} else if (x <= 2e-26) {
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+71)) then
tmp = t_0
else if (x <= (-7.2d-167)) then
tmp = t_1
else if (x <= (-1.25d-258)) then
tmp = 4.0d0
else if (x <= 2.8d-291) then
tmp = t_1
else if (x <= 4.1d-136) then
tmp = 4.0d0
else if (x <= 2d-26) 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+71) {
tmp = t_0;
} else if (x <= -7.2e-167) {
tmp = t_1;
} else if (x <= -1.25e-258) {
tmp = 4.0;
} else if (x <= 2.8e-291) {
tmp = t_1;
} else if (x <= 4.1e-136) {
tmp = 4.0;
} else if (x <= 2e-26) {
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+71: tmp = t_0 elif x <= -7.2e-167: tmp = t_1 elif x <= -1.25e-258: tmp = 4.0 elif x <= 2.8e-291: tmp = t_1 elif x <= 4.1e-136: tmp = 4.0 elif x <= 2e-26: 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+71) tmp = t_0; elseif (x <= -7.2e-167) tmp = t_1; elseif (x <= -1.25e-258) tmp = 4.0; elseif (x <= 2.8e-291) tmp = t_1; elseif (x <= 4.1e-136) tmp = 4.0; elseif (x <= 2e-26) 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+71) tmp = t_0; elseif (x <= -7.2e-167) tmp = t_1; elseif (x <= -1.25e-258) tmp = 4.0; elseif (x <= 2.8e-291) tmp = t_1; elseif (x <= 4.1e-136) tmp = 4.0; elseif (x <= 2e-26) 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+71], t$95$0, If[LessEqual[x, -7.2e-167], t$95$1, If[LessEqual[x, -1.25e-258], 4.0, If[LessEqual[x, 2.8e-291], t$95$1, If[LessEqual[x, 4.1e-136], 4.0, If[LessEqual[x, 2e-26], 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^{+71}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{-167}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.25 \cdot 10^{-258}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-291}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-136}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.50000000000000043e71 or 2.0000000000000001e-26 < x Initial program 100.0%
Taylor expanded in x around inf 71.2%
if -4.50000000000000043e71 < x < -7.2000000000000002e-167 or -1.25e-258 < x < 2.8e-291 or 4.10000000000000025e-136 < x < 2.0000000000000001e-26Initial program 99.9%
Taylor expanded in z around inf 64.3%
*-commutative64.3%
Simplified64.3%
if -7.2000000000000002e-167 < x < -1.25e-258 or 2.8e-291 < x < 4.10000000000000025e-136Initial program 100.0%
Taylor expanded in y around inf 68.0%
Final simplification68.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (* z (/ -4.0 y))))
(if (<= x -6.8e+77)
t_0
(if (<= x -1.52e-167)
t_1
(if (<= x -7.2e-259)
4.0
(if (<= x 8.2e-294)
t_1
(if (<= x 2.2e-136) 4.0 (if (<= x 6.5e-27) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = z * (-4.0 / y);
double tmp;
if (x <= -6.8e+77) {
tmp = t_0;
} else if (x <= -1.52e-167) {
tmp = t_1;
} else if (x <= -7.2e-259) {
tmp = 4.0;
} else if (x <= 8.2e-294) {
tmp = t_1;
} else if (x <= 2.2e-136) {
tmp = 4.0;
} else if (x <= 6.5e-27) {
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 = z * ((-4.0d0) / y)
if (x <= (-6.8d+77)) then
tmp = t_0
else if (x <= (-1.52d-167)) then
tmp = t_1
else if (x <= (-7.2d-259)) then
tmp = 4.0d0
else if (x <= 8.2d-294) then
tmp = t_1
else if (x <= 2.2d-136) then
tmp = 4.0d0
else if (x <= 6.5d-27) 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 = z * (-4.0 / y);
double tmp;
if (x <= -6.8e+77) {
tmp = t_0;
} else if (x <= -1.52e-167) {
tmp = t_1;
} else if (x <= -7.2e-259) {
tmp = 4.0;
} else if (x <= 8.2e-294) {
tmp = t_1;
} else if (x <= 2.2e-136) {
tmp = 4.0;
} else if (x <= 6.5e-27) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = z * (-4.0 / y) tmp = 0 if x <= -6.8e+77: tmp = t_0 elif x <= -1.52e-167: tmp = t_1 elif x <= -7.2e-259: tmp = 4.0 elif x <= 8.2e-294: tmp = t_1 elif x <= 2.2e-136: tmp = 4.0 elif x <= 6.5e-27: 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(z * Float64(-4.0 / y)) tmp = 0.0 if (x <= -6.8e+77) tmp = t_0; elseif (x <= -1.52e-167) tmp = t_1; elseif (x <= -7.2e-259) tmp = 4.0; elseif (x <= 8.2e-294) tmp = t_1; elseif (x <= 2.2e-136) tmp = 4.0; elseif (x <= 6.5e-27) 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 = z * (-4.0 / y); tmp = 0.0; if (x <= -6.8e+77) tmp = t_0; elseif (x <= -1.52e-167) tmp = t_1; elseif (x <= -7.2e-259) tmp = 4.0; elseif (x <= 8.2e-294) tmp = t_1; elseif (x <= 2.2e-136) tmp = 4.0; elseif (x <= 6.5e-27) 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[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.8e+77], t$95$0, If[LessEqual[x, -1.52e-167], t$95$1, If[LessEqual[x, -7.2e-259], 4.0, If[LessEqual[x, 8.2e-294], t$95$1, If[LessEqual[x, 2.2e-136], 4.0, If[LessEqual[x, 6.5e-27], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := z \cdot \frac{-4}{y}\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{+77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.52 \cdot 10^{-167}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{-259}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-294}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-136}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-27}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.79999999999999993e77 or 6.50000000000000025e-27 < x Initial program 100.0%
Taylor expanded in x around inf 71.2%
if -6.79999999999999993e77 < x < -1.52e-167 or -7.1999999999999996e-259 < x < 8.1999999999999998e-294 or 2.2000000000000001e-136 < x < 6.50000000000000025e-27Initial program 99.9%
Taylor expanded in z around inf 64.3%
associate-*r/64.3%
*-commutative64.3%
associate-/l*64.1%
Simplified64.1%
if -1.52e-167 < x < -7.1999999999999996e-259 or 8.1999999999999998e-294 < x < 2.2000000000000001e-136Initial program 100.0%
Taylor expanded in y around inf 68.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.3e+74) (not (<= x 2.1e-26))) (+ 4.0 (* x (/ 4.0 y))) (+ 4.0 (/ (/ z -0.25) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.3e+74) || !(x <= 2.1e-26)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 + ((z / -0.25) / 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 ((x <= (-5.3d+74)) .or. (.not. (x <= 2.1d-26))) then
tmp = 4.0d0 + (x * (4.0d0 / y))
else
tmp = 4.0d0 + ((z / (-0.25d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.3e+74) || !(x <= 2.1e-26)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 + ((z / -0.25) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.3e+74) or not (x <= 2.1e-26): tmp = 4.0 + (x * (4.0 / y)) else: tmp = 4.0 + ((z / -0.25) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.3e+74) || !(x <= 2.1e-26)) tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); else tmp = Float64(4.0 + Float64(Float64(z / -0.25) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.3e+74) || ~((x <= 2.1e-26))) tmp = 4.0 + (x * (4.0 / y)); else tmp = 4.0 + ((z / -0.25) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.3e+74], N[Not[LessEqual[x, 2.1e-26]], $MachinePrecision]], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z / -0.25), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.3 \cdot 10^{+74} \lor \neg \left(x \leq 2.1 \cdot 10^{-26}\right):\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{\frac{z}{-0.25}}{y}\\
\end{array}
\end{array}
if x < -5.2999999999999998e74 or 2.10000000000000008e-26 < x 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 z around 0 88.0%
distribute-lft-in88.0%
metadata-eval88.0%
associate-+r+88.0%
metadata-eval88.0%
associate-*r/88.0%
*-commutative88.0%
associate-*r/87.8%
Simplified87.8%
if -5.2999999999999998e74 < x < 2.10000000000000008e-26Initial 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-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 95.4%
sub-neg95.4%
distribute-lft-in95.4%
metadata-eval95.4%
associate-+r+95.4%
metadata-eval95.4%
neg-mul-195.4%
associate-*r*95.4%
metadata-eval95.4%
associate-*r/95.4%
*-commutative95.4%
associate-/l*95.3%
Simplified95.3%
clear-num95.3%
un-div-inv95.4%
div-inv95.4%
metadata-eval95.4%
Applied egg-rr95.4%
*-commutative95.4%
associate-/r*95.4%
Simplified95.4%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.25e+75) (not (<= x 5.8e-27))) (+ 4.0 (* x (/ 4.0 y))) (+ 4.0 (* z (/ -4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.25e+75) || !(x <= 5.8e-27)) {
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 ((x <= (-3.25d+75)) .or. (.not. (x <= 5.8d-27))) 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 ((x <= -3.25e+75) || !(x <= 5.8e-27)) {
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 (x <= -3.25e+75) or not (x <= 5.8e-27): 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 ((x <= -3.25e+75) || !(x <= 5.8e-27)) 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 ((x <= -3.25e+75) || ~((x <= 5.8e-27))) 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[Or[LessEqual[x, -3.25e+75], N[Not[LessEqual[x, 5.8e-27]], $MachinePrecision]], 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}\;x \leq -3.25 \cdot 10^{+75} \lor \neg \left(x \leq 5.8 \cdot 10^{-27}\right):\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\end{array}
\end{array}
if x < -3.2499999999999999e75 or 5.80000000000000008e-27 < x 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 z around 0 88.0%
distribute-lft-in88.0%
metadata-eval88.0%
associate-+r+88.0%
metadata-eval88.0%
associate-*r/88.0%
*-commutative88.0%
associate-*r/87.8%
Simplified87.8%
if -3.2499999999999999e75 < x < 5.80000000000000008e-27Initial 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-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 95.4%
sub-neg95.4%
distribute-lft-in95.4%
metadata-eval95.4%
associate-+r+95.4%
metadata-eval95.4%
neg-mul-195.4%
associate-*r*95.4%
metadata-eval95.4%
associate-*r/95.4%
*-commutative95.4%
associate-/l*95.3%
Simplified95.3%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.1e-21) (not (<= y 1.3e+14))) (+ 4.0 (* x (/ 4.0 y))) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.1e-21) || !(y <= 1.3e+14)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 * ((x - z) / 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 <= (-6.1d-21)) .or. (.not. (y <= 1.3d+14))) then
tmp = 4.0d0 + (x * (4.0d0 / y))
else
tmp = 4.0d0 * ((x - z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.1e-21) || !(y <= 1.3e+14)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.1e-21) or not (y <= 1.3e+14): tmp = 4.0 + (x * (4.0 / y)) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.1e-21) || !(y <= 1.3e+14)) tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); else tmp = Float64(4.0 * Float64(Float64(x - z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.1e-21) || ~((y <= 1.3e+14))) tmp = 4.0 + (x * (4.0 / y)); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.1e-21], N[Not[LessEqual[y, 1.3e+14]], $MachinePrecision]], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.1 \cdot 10^{-21} \lor \neg \left(y \leq 1.3 \cdot 10^{+14}\right):\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -6.10000000000000013e-21 or 1.3e14 < 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 z around 0 80.6%
distribute-lft-in80.6%
metadata-eval80.6%
associate-+r+80.6%
metadata-eval80.6%
associate-*r/80.6%
*-commutative80.6%
associate-*r/80.5%
Simplified80.5%
if -6.10000000000000013e-21 < y < 1.3e14Initial program 100.0%
Taylor expanded in y around 0 92.3%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (<= y -5.8e+86) 4.0 (if (<= y 8e+171) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+86) {
tmp = 4.0;
} else if (y <= 8e+171) {
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 <= (-5.8d+86)) then
tmp = 4.0d0
else if (y <= 8d+171) 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 <= -5.8e+86) {
tmp = 4.0;
} else if (y <= 8e+171) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.8e+86: tmp = 4.0 elif y <= 8e+171: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.8e+86) tmp = 4.0; elseif (y <= 8e+171) 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 <= -5.8e+86) tmp = 4.0; elseif (y <= 8e+171) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.8e+86], 4.0, If[LessEqual[y, 8e+171], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+86}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+171}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -5.79999999999999981e86 or 7.99999999999999963e171 < y Initial program 99.9%
Taylor expanded in y around inf 72.0%
if -5.79999999999999981e86 < y < 7.99999999999999963e171Initial program 100.0%
Taylor expanded in y around 0 82.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -4e+69) (not (<= x 2.7e+35))) (* 4.0 (/ x y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+69) || !(x <= 2.7e+35)) {
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 ((x <= (-4d+69)) .or. (.not. (x <= 2.7d+35))) 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 ((x <= -4e+69) || !(x <= 2.7e+35)) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4e+69) or not (x <= 2.7e+35): tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4e+69) || !(x <= 2.7e+35)) 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 ((x <= -4e+69) || ~((x <= 2.7e+35))) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4e+69], N[Not[LessEqual[x, 2.7e+35]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+69} \lor \neg \left(x \leq 2.7 \cdot 10^{+35}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -4.0000000000000003e69 or 2.70000000000000003e35 < x Initial program 100.0%
Taylor expanded in x around inf 74.6%
if -4.0000000000000003e69 < x < 2.70000000000000003e35Initial program 99.9%
Taylor expanded in y around inf 44.6%
Final simplification56.4%
(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 100.0%
Taylor expanded in y around inf 32.7%
herbie shell --seed 2024157
(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)))