
(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 11 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 99.9%
Taylor expanded in y around inf 100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= x -3.5e+44)
t_0
(if (<= x -5.5e-286) (* -4.0 (/ z y)) (if (<= x 1.8e+120) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (x <= -3.5e+44) {
tmp = t_0;
} else if (x <= -5.5e-286) {
tmp = -4.0 * (z / y);
} else if (x <= 1.8e+120) {
tmp = 4.0;
} 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) :: tmp
t_0 = 4.0d0 * (x / y)
if (x <= (-3.5d+44)) then
tmp = t_0
else if (x <= (-5.5d-286)) then
tmp = (-4.0d0) * (z / y)
else if (x <= 1.8d+120) then
tmp = 4.0d0
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 tmp;
if (x <= -3.5e+44) {
tmp = t_0;
} else if (x <= -5.5e-286) {
tmp = -4.0 * (z / y);
} else if (x <= 1.8e+120) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if x <= -3.5e+44: tmp = t_0 elif x <= -5.5e-286: tmp = -4.0 * (z / y) elif x <= 1.8e+120: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -3.5e+44) tmp = t_0; elseif (x <= -5.5e-286) tmp = Float64(-4.0 * Float64(z / y)); elseif (x <= 1.8e+120) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); tmp = 0.0; if (x <= -3.5e+44) tmp = t_0; elseif (x <= -5.5e-286) tmp = -4.0 * (z / y); elseif (x <= 1.8e+120) tmp = 4.0; 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]}, If[LessEqual[x, -3.5e+44], t$95$0, If[LessEqual[x, -5.5e-286], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8e+120], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.5 \cdot 10^{-286}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+120}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.4999999999999999e44 or 1.80000000000000008e120 < x Initial program 99.9%
Taylor expanded in x around inf 72.0%
if -3.4999999999999999e44 < x < -5.4999999999999998e-286Initial program 99.9%
Taylor expanded in z around inf 55.9%
*-commutative55.9%
Simplified55.9%
if -5.4999999999999998e-286 < x < 1.80000000000000008e120Initial program 99.9%
Taylor expanded in y around inf 55.1%
Final simplification61.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= x -1.05e+44)
t_0
(if (<= x -8e-286) (* z (/ -4.0 y)) (if (<= x 1.8e+120) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (x <= -1.05e+44) {
tmp = t_0;
} else if (x <= -8e-286) {
tmp = z * (-4.0 / y);
} else if (x <= 1.8e+120) {
tmp = 4.0;
} 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) :: tmp
t_0 = 4.0d0 * (x / y)
if (x <= (-1.05d+44)) then
tmp = t_0
else if (x <= (-8d-286)) then
tmp = z * ((-4.0d0) / y)
else if (x <= 1.8d+120) then
tmp = 4.0d0
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 tmp;
if (x <= -1.05e+44) {
tmp = t_0;
} else if (x <= -8e-286) {
tmp = z * (-4.0 / y);
} else if (x <= 1.8e+120) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if x <= -1.05e+44: tmp = t_0 elif x <= -8e-286: tmp = z * (-4.0 / y) elif x <= 1.8e+120: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -1.05e+44) tmp = t_0; elseif (x <= -8e-286) tmp = Float64(z * Float64(-4.0 / y)); elseif (x <= 1.8e+120) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); tmp = 0.0; if (x <= -1.05e+44) tmp = t_0; elseif (x <= -8e-286) tmp = z * (-4.0 / y); elseif (x <= 1.8e+120) tmp = 4.0; 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]}, If[LessEqual[x, -1.05e+44], t$95$0, If[LessEqual[x, -8e-286], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8e+120], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -8 \cdot 10^{-286}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+120}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.04999999999999993e44 or 1.80000000000000008e120 < x Initial program 99.9%
Taylor expanded in x around inf 72.0%
if -1.04999999999999993e44 < x < -8.0000000000000004e-286Initial program 99.9%
Taylor expanded in z around inf 55.9%
associate-*r/55.9%
*-commutative55.9%
associate-/l*55.7%
Simplified55.7%
if -8.0000000000000004e-286 < x < 1.80000000000000008e120Initial program 99.9%
Taylor expanded in y around inf 55.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.7e+65) (not (<= y 1.06e+68))) (+ 4.0 (* x (/ 4.0 y))) (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.7e+65) || !(y <= 1.06e+68)) {
tmp = 4.0 + (x * (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.7d+65)) .or. (.not. (y <= 1.06d+68))) then
tmp = 4.0d0 + (x * (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.7e+65) || !(y <= 1.06e+68)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = (x - z) * (4.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.7e+65) or not (y <= 1.06e+68): tmp = 4.0 + (x * (4.0 / y)) else: tmp = (x - z) * (4.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.7e+65) || !(y <= 1.06e+68)) tmp = Float64(4.0 + Float64(x * Float64(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.7e+65) || ~((y <= 1.06e+68))) tmp = 4.0 + (x * (4.0 / y)); else tmp = (x - z) * (4.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.7e+65], N[Not[LessEqual[y, 1.06e+68]], $MachinePrecision]], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+65} \lor \neg \left(y \leq 1.06 \cdot 10^{+68}\right):\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -3.69999999999999995e65 or 1.06e68 < 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 84.6%
distribute-lft-in84.6%
metadata-eval84.6%
associate-+r+84.6%
metadata-eval84.6%
associate-*r/84.6%
*-commutative84.6%
associate-*r/84.6%
Simplified84.6%
if -3.69999999999999995e65 < y < 1.06e68Initial program 99.9%
Taylor expanded in y around 0 88.3%
*-lft-identity88.3%
associate-*l/88.0%
associate-*r*88.0%
associate-*r/88.0%
metadata-eval88.0%
Simplified88.0%
Final simplification86.5%
(FPCore (x y z) :precision binary64 (if (<= x -2.3e+36) (/ 4.0 (/ y (- x z))) (if (<= x 3.1e+120) (+ 4.0 (/ (* z -4.0) y)) (+ 4.0 (/ (* 4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.3e+36) {
tmp = 4.0 / (y / (x - z));
} else if (x <= 3.1e+120) {
tmp = 4.0 + ((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 (x <= (-2.3d+36)) then
tmp = 4.0d0 / (y / (x - z))
else if (x <= 3.1d+120) then
tmp = 4.0d0 + ((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 (x <= -2.3e+36) {
tmp = 4.0 / (y / (x - z));
} else if (x <= 3.1e+120) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 + ((4.0 * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.3e+36: tmp = 4.0 / (y / (x - z)) elif x <= 3.1e+120: tmp = 4.0 + ((z * -4.0) / y) else: tmp = 4.0 + ((4.0 * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.3e+36) tmp = Float64(4.0 / Float64(y / Float64(x - z))); elseif (x <= 3.1e+120) tmp = Float64(4.0 + Float64(Float64(z * -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 (x <= -2.3e+36) tmp = 4.0 / (y / (x - z)); elseif (x <= 3.1e+120) tmp = 4.0 + ((z * -4.0) / y); else tmp = 4.0 + ((4.0 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.3e+36], N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e+120], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+36}:\\
\;\;\;\;\frac{4}{\frac{y}{x - z}}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+120}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\end{array}
\end{array}
if x < -2.29999999999999996e36Initial program 99.9%
Taylor expanded in y around 0 83.8%
*-lft-identity83.8%
associate-*l/83.5%
associate-*r*83.5%
associate-*r/83.5%
metadata-eval83.5%
Simplified83.5%
associate-/r/83.6%
Applied egg-rr83.6%
if -2.29999999999999996e36 < x < 3.09999999999999974e120Initial program 99.9%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around 0 92.2%
+-commutative92.2%
associate-*r/92.2%
Simplified92.2%
if 3.09999999999999974e120 < 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 89.1%
distribute-lft-in89.1%
metadata-eval89.1%
associate-+r+89.1%
metadata-eval89.1%
associate-*r/89.1%
*-commutative89.1%
associate-*r/88.8%
Simplified88.8%
*-commutative88.8%
associate-*l/89.1%
Applied egg-rr89.1%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (<= x -2.05e+36) (* (- x z) (/ 4.0 y)) (if (<= x 4.7e+120) (+ 4.0 (/ (* z -4.0) y)) (+ 4.0 (/ (* 4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.05e+36) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 4.7e+120) {
tmp = 4.0 + ((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 (x <= (-2.05d+36)) then
tmp = (x - z) * (4.0d0 / y)
else if (x <= 4.7d+120) then
tmp = 4.0d0 + ((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 (x <= -2.05e+36) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 4.7e+120) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 + ((4.0 * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.05e+36: tmp = (x - z) * (4.0 / y) elif x <= 4.7e+120: tmp = 4.0 + ((z * -4.0) / y) else: tmp = 4.0 + ((4.0 * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.05e+36) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (x <= 4.7e+120) tmp = Float64(4.0 + Float64(Float64(z * -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 (x <= -2.05e+36) tmp = (x - z) * (4.0 / y); elseif (x <= 4.7e+120) tmp = 4.0 + ((z * -4.0) / y); else tmp = 4.0 + ((4.0 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.05e+36], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e+120], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.05 \cdot 10^{+36}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{+120}:\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\end{array}
\end{array}
if x < -2.05000000000000006e36Initial program 99.9%
Taylor expanded in y around 0 83.8%
*-lft-identity83.8%
associate-*l/83.5%
associate-*r*83.5%
associate-*r/83.5%
metadata-eval83.5%
Simplified83.5%
if -2.05000000000000006e36 < x < 4.69999999999999993e120Initial program 99.9%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around 0 92.2%
+-commutative92.2%
associate-*r/92.2%
Simplified92.2%
if 4.69999999999999993e120 < 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 89.1%
distribute-lft-in89.1%
metadata-eval89.1%
associate-+r+89.1%
metadata-eval89.1%
associate-*r/89.1%
*-commutative89.1%
associate-*r/88.8%
Simplified88.8%
*-commutative88.8%
associate-*l/89.1%
Applied egg-rr89.1%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (<= x -1.2e+36) (* (- x z) (/ 4.0 y)) (if (<= x 3.1e+120) (+ 4.0 (* z (/ -4.0 y))) (+ 4.0 (/ (* 4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.2e+36) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 3.1e+120) {
tmp = 4.0 + (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 (x <= (-1.2d+36)) then
tmp = (x - z) * (4.0d0 / y)
else if (x <= 3.1d+120) then
tmp = 4.0d0 + (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 (x <= -1.2e+36) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 3.1e+120) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.0 + ((4.0 * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.2e+36: tmp = (x - z) * (4.0 / y) elif x <= 3.1e+120: tmp = 4.0 + (z * (-4.0 / y)) else: tmp = 4.0 + ((4.0 * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.2e+36) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (x <= 3.1e+120) tmp = Float64(4.0 + Float64(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 (x <= -1.2e+36) tmp = (x - z) * (4.0 / y); elseif (x <= 3.1e+120) tmp = 4.0 + (z * (-4.0 / y)); else tmp = 4.0 + ((4.0 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.2e+36], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.1e+120], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+36}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+120}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{4 \cdot x}{y}\\
\end{array}
\end{array}
if x < -1.19999999999999996e36Initial program 99.9%
Taylor expanded in y around 0 83.8%
*-lft-identity83.8%
associate-*l/83.5%
associate-*r*83.5%
associate-*r/83.5%
metadata-eval83.5%
Simplified83.5%
if -1.19999999999999996e36 < x < 3.09999999999999974e120Initial 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 92.2%
sub-neg92.2%
distribute-lft-in92.2%
metadata-eval92.2%
associate-+r+92.2%
metadata-eval92.2%
neg-mul-192.2%
associate-*r*92.2%
metadata-eval92.2%
associate-*r/92.2%
*-commutative92.2%
associate-/l*92.0%
Simplified92.0%
if 3.09999999999999974e120 < 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 89.1%
distribute-lft-in89.1%
metadata-eval89.1%
associate-+r+89.1%
metadata-eval89.1%
associate-*r/89.1%
*-commutative89.1%
associate-*r/88.8%
Simplified88.8%
*-commutative88.8%
associate-*l/89.1%
Applied egg-rr89.1%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (<= x -2.15e+36) (* (- x z) (/ 4.0 y)) (if (<= x 4.3e+123) (+ 4.0 (* z (/ -4.0 y))) (+ 4.0 (* x (/ 4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.15e+36) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 4.3e+123) {
tmp = 4.0 + (z * (-4.0 / 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 (x <= (-2.15d+36)) then
tmp = (x - z) * (4.0d0 / y)
else if (x <= 4.3d+123) then
tmp = 4.0d0 + (z * ((-4.0d0) / 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 (x <= -2.15e+36) {
tmp = (x - z) * (4.0 / y);
} else if (x <= 4.3e+123) {
tmp = 4.0 + (z * (-4.0 / y));
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.15e+36: tmp = (x - z) * (4.0 / y) elif x <= 4.3e+123: tmp = 4.0 + (z * (-4.0 / y)) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.15e+36) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); elseif (x <= 4.3e+123) tmp = Float64(4.0 + Float64(z * Float64(-4.0 / 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 (x <= -2.15e+36) tmp = (x - z) * (4.0 / y); elseif (x <= 4.3e+123) tmp = 4.0 + (z * (-4.0 / y)); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.15e+36], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.3e+123], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{+36}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{+123}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if x < -2.15000000000000002e36Initial program 99.9%
Taylor expanded in y around 0 83.8%
*-lft-identity83.8%
associate-*l/83.5%
associate-*r*83.5%
associate-*r/83.5%
metadata-eval83.5%
Simplified83.5%
if -2.15000000000000002e36 < x < 4.29999999999999986e123Initial 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 92.2%
sub-neg92.2%
distribute-lft-in92.2%
metadata-eval92.2%
associate-+r+92.2%
metadata-eval92.2%
neg-mul-192.2%
associate-*r*92.2%
metadata-eval92.2%
associate-*r/92.2%
*-commutative92.2%
associate-/l*92.0%
Simplified92.0%
if 4.29999999999999986e123 < 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 89.1%
distribute-lft-in89.1%
metadata-eval89.1%
associate-+r+89.1%
metadata-eval89.1%
associate-*r/89.1%
*-commutative89.1%
associate-*r/88.8%
Simplified88.8%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.15e+85) 4.0 (if (<= y 9e+161) (* (- x z) (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+85) {
tmp = 4.0;
} else if (y <= 9e+161) {
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 <= (-1.15d+85)) then
tmp = 4.0d0
else if (y <= 9d+161) 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 <= -1.15e+85) {
tmp = 4.0;
} else if (y <= 9e+161) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.15e+85: tmp = 4.0 elif y <= 9e+161: tmp = (x - z) * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.15e+85) tmp = 4.0; elseif (y <= 9e+161) 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 <= -1.15e+85) tmp = 4.0; elseif (y <= 9e+161) tmp = (x - z) * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.15e+85], 4.0, If[LessEqual[y, 9e+161], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+85}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+161}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.1499999999999999e85 or 8.99999999999999984e161 < y Initial program 99.9%
Taylor expanded in y around inf 72.9%
if -1.1499999999999999e85 < y < 8.99999999999999984e161Initial program 99.9%
Taylor expanded in y around 0 84.2%
*-lft-identity84.2%
associate-*l/83.9%
associate-*r*83.9%
associate-*r/83.9%
metadata-eval83.9%
Simplified83.9%
Final simplification80.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -6.4e+35) (not (<= x 2.05e+120))) (* 4.0 (/ x y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.4e+35) || !(x <= 2.05e+120)) {
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 <= (-6.4d+35)) .or. (.not. (x <= 2.05d+120))) 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 <= -6.4e+35) || !(x <= 2.05e+120)) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.4e+35) or not (x <= 2.05e+120): tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.4e+35) || !(x <= 2.05e+120)) 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 <= -6.4e+35) || ~((x <= 2.05e+120))) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.4e+35], N[Not[LessEqual[x, 2.05e+120]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{+35} \lor \neg \left(x \leq 2.05 \cdot 10^{+120}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -6.39999999999999965e35 or 2.05e120 < x Initial program 99.9%
Taylor expanded in x around inf 71.5%
if -6.39999999999999965e35 < x < 2.05e120Initial program 99.9%
Taylor expanded in y around inf 49.3%
Final simplification57.3%
(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 36.3%
herbie shell --seed 2024144
(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)))