
(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 (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 98.8%
+-commutative98.8%
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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= x -3500.0)
t_0
(if (<= x -1.66e-121) (* (/ z y) -4.0) (if (<= x 4.1e+41) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (x <= -3500.0) {
tmp = t_0;
} else if (x <= -1.66e-121) {
tmp = (z / y) * -4.0;
} else if (x <= 4.1e+41) {
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 <= (-3500.0d0)) then
tmp = t_0
else if (x <= (-1.66d-121)) then
tmp = (z / y) * (-4.0d0)
else if (x <= 4.1d+41) 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 <= -3500.0) {
tmp = t_0;
} else if (x <= -1.66e-121) {
tmp = (z / y) * -4.0;
} else if (x <= 4.1e+41) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if x <= -3500.0: tmp = t_0 elif x <= -1.66e-121: tmp = (z / y) * -4.0 elif x <= 4.1e+41: 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 <= -3500.0) tmp = t_0; elseif (x <= -1.66e-121) tmp = Float64(Float64(z / y) * -4.0); elseif (x <= 4.1e+41) 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 <= -3500.0) tmp = t_0; elseif (x <= -1.66e-121) tmp = (z / y) * -4.0; elseif (x <= 4.1e+41) 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, -3500.0], t$95$0, If[LessEqual[x, -1.66e-121], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], If[LessEqual[x, 4.1e+41], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -3500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.66 \cdot 10^{-121}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+41}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3500 or 4.1000000000000004e41 < x Initial program 98.4%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 78.2%
*-commutative78.2%
Simplified78.2%
if -3500 < x < -1.6600000000000001e-121Initial program 96.4%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 61.3%
*-commutative61.3%
Simplified61.3%
if -1.6600000000000001e-121 < x < 4.1000000000000004e41Initial program 99.8%
associate-/l*99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 54.2%
Final simplification66.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= x -370000.0)
t_0
(if (<= x -5.8e-123) (* z (/ -4.0 y)) (if (<= x 3.9e+37) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (x <= -370000.0) {
tmp = t_0;
} else if (x <= -5.8e-123) {
tmp = z * (-4.0 / y);
} else if (x <= 3.9e+37) {
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 <= (-370000.0d0)) then
tmp = t_0
else if (x <= (-5.8d-123)) then
tmp = z * ((-4.0d0) / y)
else if (x <= 3.9d+37) 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 <= -370000.0) {
tmp = t_0;
} else if (x <= -5.8e-123) {
tmp = z * (-4.0 / y);
} else if (x <= 3.9e+37) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if x <= -370000.0: tmp = t_0 elif x <= -5.8e-123: tmp = z * (-4.0 / y) elif x <= 3.9e+37: 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 <= -370000.0) tmp = t_0; elseif (x <= -5.8e-123) tmp = Float64(z * Float64(-4.0 / y)); elseif (x <= 3.9e+37) 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 <= -370000.0) tmp = t_0; elseif (x <= -5.8e-123) tmp = z * (-4.0 / y); elseif (x <= 3.9e+37) 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, -370000.0], t$95$0, If[LessEqual[x, -5.8e-123], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.9e+37], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -370000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-123}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{+37}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.7e5 or 3.8999999999999999e37 < x Initial program 98.4%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 78.2%
*-commutative78.2%
Simplified78.2%
if -3.7e5 < x < -5.80000000000000007e-123Initial program 96.4%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 61.3%
*-commutative61.3%
Simplified61.3%
Taylor expanded in z around 0 61.3%
associate-*r/61.3%
*-commutative61.3%
associate-*r/61.1%
Simplified61.1%
if -5.80000000000000007e-123 < x < 3.8999999999999999e37Initial program 99.8%
associate-/l*99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 54.2%
Final simplification66.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 y))))
(if (<= x -550000.0)
t_0
(if (<= x -2.5e-121) (* z (/ -4.0 y)) (if (<= x 6e+36) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double tmp;
if (x <= -550000.0) {
tmp = t_0;
} else if (x <= -2.5e-121) {
tmp = z * (-4.0 / y);
} else if (x <= 6e+36) {
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 = x * (4.0d0 / y)
if (x <= (-550000.0d0)) then
tmp = t_0
else if (x <= (-2.5d-121)) then
tmp = z * ((-4.0d0) / y)
else if (x <= 6d+36) 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 = x * (4.0 / y);
double tmp;
if (x <= -550000.0) {
tmp = t_0;
} else if (x <= -2.5e-121) {
tmp = z * (-4.0 / y);
} else if (x <= 6e+36) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / y) tmp = 0 if x <= -550000.0: tmp = t_0 elif x <= -2.5e-121: tmp = z * (-4.0 / y) elif x <= 6e+36: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / y)) tmp = 0.0 if (x <= -550000.0) tmp = t_0; elseif (x <= -2.5e-121) tmp = Float64(z * Float64(-4.0 / y)); elseif (x <= 6e+36) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / y); tmp = 0.0; if (x <= -550000.0) tmp = t_0; elseif (x <= -2.5e-121) tmp = z * (-4.0 / y); elseif (x <= 6e+36) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -550000.0], t$95$0, If[LessEqual[x, -2.5e-121], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6e+36], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -550000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-121}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+36}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.5e5 or 6e36 < x Initial program 98.4%
+-commutative98.4%
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.4%
distribute-lft-in88.4%
metadata-eval88.4%
associate-+r+88.4%
metadata-eval88.4%
*-commutative88.4%
Simplified88.4%
Taylor expanded in x around 0 88.4%
+-commutative88.4%
associate-*r/87.7%
*-commutative87.7%
associate-*r/88.2%
metadata-eval88.2%
associate-*r/88.2%
fma-define88.3%
associate-*r/88.3%
metadata-eval88.3%
Simplified88.3%
Taylor expanded in x around inf 78.2%
associate-*r/77.5%
*-commutative77.5%
associate-*r/78.1%
Simplified78.1%
if -5.5e5 < x < -2.49999999999999995e-121Initial program 96.4%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 61.3%
*-commutative61.3%
Simplified61.3%
Taylor expanded in z around 0 61.3%
associate-*r/61.3%
*-commutative61.3%
associate-*r/61.1%
Simplified61.1%
if -2.49999999999999995e-121 < x < 6e36Initial program 99.8%
associate-/l*99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 54.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.2e+81) (not (<= z 5.5e+93))) (* 4.0 (/ (- x z) y)) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.2e+81) || !(z <= 5.5e+93)) {
tmp = 4.0 * ((x - z) / 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 <= (-9.2d+81)) .or. (.not. (z <= 5.5d+93))) then
tmp = 4.0d0 * ((x - z) / 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 <= -9.2e+81) || !(z <= 5.5e+93)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.2e+81) or not (z <= 5.5e+93): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.2e+81) || !(z <= 5.5e+93)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9.2e+81) || ~((z <= 5.5e+93))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.2e+81], N[Not[LessEqual[z, 5.5e+93]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \cdot 10^{+81} \lor \neg \left(z \leq 5.5 \cdot 10^{+93}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -9.1999999999999995e81 or 5.5000000000000003e93 < z Initial program 96.8%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 85.2%
*-commutative85.2%
Simplified85.2%
if -9.1999999999999995e81 < z < 5.5000000000000003e93Initial 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 90.9%
distribute-lft-in90.9%
metadata-eval90.9%
associate-+r+90.9%
metadata-eval90.9%
*-commutative90.9%
Simplified90.9%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (<= x -170000.0) (+ 4.0 (* 4.0 (/ x y))) (if (<= x 2.9e+38) (+ 4.0 (* (/ z y) -4.0)) (* 4.0 (/ (- x z) y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -170000.0) {
tmp = 4.0 + (4.0 * (x / y));
} else if (x <= 2.9e+38) {
tmp = 4.0 + ((z / y) * -4.0);
} 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 (x <= (-170000.0d0)) then
tmp = 4.0d0 + (4.0d0 * (x / y))
else if (x <= 2.9d+38) then
tmp = 4.0d0 + ((z / y) * (-4.0d0))
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 (x <= -170000.0) {
tmp = 4.0 + (4.0 * (x / y));
} else if (x <= 2.9e+38) {
tmp = 4.0 + ((z / y) * -4.0);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -170000.0: tmp = 4.0 + (4.0 * (x / y)) elif x <= 2.9e+38: tmp = 4.0 + ((z / y) * -4.0) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -170000.0) tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); elseif (x <= 2.9e+38) tmp = Float64(4.0 + Float64(Float64(z / y) * -4.0)); 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 (x <= -170000.0) tmp = 4.0 + (4.0 * (x / y)); elseif (x <= 2.9e+38) tmp = 4.0 + ((z / y) * -4.0); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -170000.0], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.9e+38], N[(4.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -170000:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+38}:\\
\;\;\;\;4 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if x < -1.7e5Initial program 97.3%
+-commutative97.3%
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 91.4%
distribute-lft-in91.4%
metadata-eval91.4%
associate-+r+91.4%
metadata-eval91.4%
*-commutative91.4%
Simplified91.4%
if -1.7e5 < x < 2.90000000000000007e38Initial program 99.2%
+-commutative99.2%
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 91.7%
sub-neg91.7%
distribute-lft-in91.7%
metadata-eval91.7%
associate-+r+91.7%
metadata-eval91.7%
neg-mul-191.7%
associate-*r*91.7%
metadata-eval91.7%
*-commutative91.7%
Simplified91.7%
if 2.90000000000000007e38 < x Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 93.0%
*-commutative93.0%
Simplified93.0%
Final simplification91.9%
(FPCore (x y z) :precision binary64 (if (<= y -7e+137) 4.0 (if (<= y 9.5e+111) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7e+137) {
tmp = 4.0;
} else if (y <= 9.5e+111) {
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 <= (-7d+137)) then
tmp = 4.0d0
else if (y <= 9.5d+111) 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 <= -7e+137) {
tmp = 4.0;
} else if (y <= 9.5e+111) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7e+137: tmp = 4.0 elif y <= 9.5e+111: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7e+137) tmp = 4.0; elseif (y <= 9.5e+111) 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 <= -7e+137) tmp = 4.0; elseif (y <= 9.5e+111) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7e+137], 4.0, If[LessEqual[y, 9.5e+111], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+137}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+111}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -7.0000000000000002e137 or 9.50000000000000019e111 < y Initial program 98.5%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 70.1%
if -7.0000000000000002e137 < y < 9.50000000000000019e111Initial program 99.0%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 83.6%
*-commutative83.6%
Simplified83.6%
Final simplification79.9%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+137) 4.0 (if (<= y 6.2e+111) (* (- x z) (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+137) {
tmp = 4.0;
} else if (y <= 6.2e+111) {
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 <= (-7.2d+137)) then
tmp = 4.0d0
else if (y <= 6.2d+111) 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 <= -7.2e+137) {
tmp = 4.0;
} else if (y <= 6.2e+111) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+137: tmp = 4.0 elif y <= 6.2e+111: tmp = (x - z) * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+137) tmp = 4.0; elseif (y <= 6.2e+111) 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 <= -7.2e+137) tmp = 4.0; elseif (y <= 6.2e+111) tmp = (x - z) * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+137], 4.0, If[LessEqual[y, 6.2e+111], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+137}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+111}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -7.1999999999999999e137 or 6.2000000000000001e111 < y Initial program 98.5%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 70.1%
if -7.1999999999999999e137 < y < 6.2000000000000001e111Initial program 99.0%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 83.6%
associate-*r/82.6%
*-commutative82.6%
associate-/l*83.3%
Simplified83.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.2e+36) (not (<= x 1.15e+37))) (* x (/ 4.0 y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.2e+36) || !(x <= 1.15e+37)) {
tmp = x * (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 ((x <= (-1.2d+36)) .or. (.not. (x <= 1.15d+37))) then
tmp = x * (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 ((x <= -1.2e+36) || !(x <= 1.15e+37)) {
tmp = x * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.2e+36) or not (x <= 1.15e+37): tmp = x * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.2e+36) || !(x <= 1.15e+37)) tmp = Float64(x * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.2e+36) || ~((x <= 1.15e+37))) tmp = x * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.2e+36], N[Not[LessEqual[x, 1.15e+37]], $MachinePrecision]], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+36} \lor \neg \left(x \leq 1.15 \cdot 10^{+37}\right):\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -1.19999999999999996e36 or 1.15000000000000001e37 < x Initial program 98.3%
+-commutative98.3%
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.4%
distribute-lft-in88.4%
metadata-eval88.4%
associate-+r+88.4%
metadata-eval88.4%
*-commutative88.4%
Simplified88.4%
Taylor expanded in x around 0 88.4%
+-commutative88.4%
associate-*r/87.6%
*-commutative87.6%
associate-*r/88.2%
metadata-eval88.2%
associate-*r/88.2%
fma-define88.2%
associate-*r/88.2%
metadata-eval88.2%
Simplified88.2%
Taylor expanded in x around inf 81.8%
associate-*r/81.0%
*-commutative81.0%
associate-*r/81.7%
Simplified81.7%
if -1.19999999999999996e36 < x < 1.15000000000000001e37Initial program 99.2%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 50.3%
Final simplification63.9%
(FPCore (x y z) :precision binary64 (+ 1.0 (* 4.0 (/ (+ x (- (* 0.75 y) z)) y))))
double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - 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 + ((0.75d0 * y) - z)) / y))
end function
public static double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y));
}
def code(x, y, z): return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y))
function code(x, y, z) return Float64(1.0 + Float64(4.0 * Float64(Float64(x + Float64(Float64(0.75 * y) - z)) / y))) end
function tmp = code(x, y, z) tmp = 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y)); end
code[x_, y_, z_] := N[(1.0 + N[(4.0 * N[(N[(x + N[(N[(0.75 * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 4 \cdot \frac{x + \left(0.75 \cdot y - z\right)}{y}
\end{array}
Initial program 98.8%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Final simplification99.9%
(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 98.8%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 31.9%
herbie shell --seed 2024138
(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)))