
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (* -4.0 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
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) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 99.6%
remove-double-neg99.6%
neg-mul-199.6%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x 4.0) z)) (t_1 (* -4.0 (/ y z))))
(if (<= z -1.5e+65)
-2.0
(if (<= z -4.9e-206)
t_1
(if (<= z 2.45e+154)
t_0
(if (<= z 1.75e+169) t_1 (if (<= z 2.6e+186) t_0 -2.0)))))))
double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (z <= -1.5e+65) {
tmp = -2.0;
} else if (z <= -4.9e-206) {
tmp = t_1;
} else if (z <= 2.45e+154) {
tmp = t_0;
} else if (z <= 1.75e+169) {
tmp = t_1;
} else if (z <= 2.6e+186) {
tmp = t_0;
} else {
tmp = -2.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 = (x * 4.0d0) / z
t_1 = (-4.0d0) * (y / z)
if (z <= (-1.5d+65)) then
tmp = -2.0d0
else if (z <= (-4.9d-206)) then
tmp = t_1
else if (z <= 2.45d+154) then
tmp = t_0
else if (z <= 1.75d+169) then
tmp = t_1
else if (z <= 2.6d+186) then
tmp = t_0
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (z <= -1.5e+65) {
tmp = -2.0;
} else if (z <= -4.9e-206) {
tmp = t_1;
} else if (z <= 2.45e+154) {
tmp = t_0;
} else if (z <= 1.75e+169) {
tmp = t_1;
} else if (z <= 2.6e+186) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 4.0) / z t_1 = -4.0 * (y / z) tmp = 0 if z <= -1.5e+65: tmp = -2.0 elif z <= -4.9e-206: tmp = t_1 elif z <= 2.45e+154: tmp = t_0 elif z <= 1.75e+169: tmp = t_1 elif z <= 2.6e+186: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 4.0) / z) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (z <= -1.5e+65) tmp = -2.0; elseif (z <= -4.9e-206) tmp = t_1; elseif (z <= 2.45e+154) tmp = t_0; elseif (z <= 1.75e+169) tmp = t_1; elseif (z <= 2.6e+186) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 4.0) / z; t_1 = -4.0 * (y / z); tmp = 0.0; if (z <= -1.5e+65) tmp = -2.0; elseif (z <= -4.9e-206) tmp = t_1; elseif (z <= 2.45e+154) tmp = t_0; elseif (z <= 1.75e+169) tmp = t_1; elseif (z <= 2.6e+186) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.5e+65], -2.0, If[LessEqual[z, -4.9e-206], t$95$1, If[LessEqual[z, 2.45e+154], t$95$0, If[LessEqual[z, 1.75e+169], t$95$1, If[LessEqual[z, 2.6e+186], t$95$0, -2.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1.5 \cdot 10^{+65}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -4.9 \cdot 10^{-206}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{+169}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+186}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.5000000000000001e65 or 2.6000000000000001e186 < z Initial program 98.8%
*-commutative98.8%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 71.7%
if -1.5000000000000001e65 < z < -4.9e-206 or 2.4500000000000001e154 < z < 1.75000000000000009e169Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 59.7%
*-commutative59.7%
Simplified59.7%
if -4.9e-206 < z < 2.4500000000000001e154 or 1.75000000000000009e169 < z < 2.6000000000000001e186Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 59.1%
associate-*r/59.1%
*-commutative59.1%
Simplified59.1%
Final simplification63.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -2e-55) (not (<= x 3.5e+31))) (* -4.0 (- 0.5 (/ x z))) (* -4.0 (+ 0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2e-55) || !(x <= 3.5e+31)) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = -4.0 * (0.5 + (y / z));
}
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 <= (-2d-55)) .or. (.not. (x <= 3.5d+31))) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else
tmp = (-4.0d0) * (0.5d0 + (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2e-55) || !(x <= 3.5e+31)) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = -4.0 * (0.5 + (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2e-55) or not (x <= 3.5e+31): tmp = -4.0 * (0.5 - (x / z)) else: tmp = -4.0 * (0.5 + (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2e-55) || !(x <= 3.5e+31)) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); else tmp = Float64(-4.0 * Float64(0.5 + Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2e-55) || ~((x <= 3.5e+31))) tmp = -4.0 * (0.5 - (x / z)); else tmp = -4.0 * (0.5 + (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2e-55], N[Not[LessEqual[x, 3.5e+31]], $MachinePrecision]], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-55} \lor \neg \left(x \leq 3.5 \cdot 10^{+31}\right):\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 + \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -1.99999999999999999e-55 or 3.5e31 < x Initial program 99.2%
remove-double-neg99.2%
neg-mul-199.2%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 86.5%
if -1.99999999999999999e-55 < x < 3.5e31Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 93.8%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.8e+97) (not (<= x 1.8e+33))) (/ (* x 4.0) z) (* -4.0 (+ 0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.8e+97) || !(x <= 1.8e+33)) {
tmp = (x * 4.0) / z;
} else {
tmp = -4.0 * (0.5 + (y / z));
}
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 <= (-8.8d+97)) .or. (.not. (x <= 1.8d+33))) then
tmp = (x * 4.0d0) / z
else
tmp = (-4.0d0) * (0.5d0 + (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.8e+97) || !(x <= 1.8e+33)) {
tmp = (x * 4.0) / z;
} else {
tmp = -4.0 * (0.5 + (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.8e+97) or not (x <= 1.8e+33): tmp = (x * 4.0) / z else: tmp = -4.0 * (0.5 + (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.8e+97) || !(x <= 1.8e+33)) tmp = Float64(Float64(x * 4.0) / z); else tmp = Float64(-4.0 * Float64(0.5 + Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.8e+97) || ~((x <= 1.8e+33))) tmp = (x * 4.0) / z; else tmp = -4.0 * (0.5 + (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.8e+97], N[Not[LessEqual[x, 1.8e+33]], $MachinePrecision]], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], N[(-4.0 * N[(0.5 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{+97} \lor \neg \left(x \leq 1.8 \cdot 10^{+33}\right):\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 + \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -8.8000000000000003e97 or 1.8000000000000001e33 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 76.5%
associate-*r/76.5%
*-commutative76.5%
Simplified76.5%
if -8.8000000000000003e97 < x < 1.8000000000000001e33Initial program 99.3%
remove-double-neg99.3%
neg-mul-199.3%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 89.0%
Final simplification83.7%
(FPCore (x y z) :precision binary64 (if (<= x -1.4e-56) (* -4.0 (- 0.5 (/ x z))) (if (<= x 3.7e-25) (* -4.0 (+ 0.5 (/ y z))) (/ (* 4.0 (- x y)) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e-56) {
tmp = -4.0 * (0.5 - (x / z));
} else if (x <= 3.7e-25) {
tmp = -4.0 * (0.5 + (y / z));
} else {
tmp = (4.0 * (x - y)) / z;
}
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.4d-56)) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else if (x <= 3.7d-25) then
tmp = (-4.0d0) * (0.5d0 + (y / z))
else
tmp = (4.0d0 * (x - y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e-56) {
tmp = -4.0 * (0.5 - (x / z));
} else if (x <= 3.7e-25) {
tmp = -4.0 * (0.5 + (y / z));
} else {
tmp = (4.0 * (x - y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.4e-56: tmp = -4.0 * (0.5 - (x / z)) elif x <= 3.7e-25: tmp = -4.0 * (0.5 + (y / z)) else: tmp = (4.0 * (x - y)) / z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.4e-56) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); elseif (x <= 3.7e-25) tmp = Float64(-4.0 * Float64(0.5 + Float64(y / z))); else tmp = Float64(Float64(4.0 * Float64(x - y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.4e-56) tmp = -4.0 * (0.5 - (x / z)); elseif (x <= 3.7e-25) tmp = -4.0 * (0.5 + (y / z)); else tmp = (4.0 * (x - y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.4e-56], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e-25], N[(-4.0 * N[(0.5 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{-56}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-25}:\\
\;\;\;\;-4 \cdot \left(0.5 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{4 \cdot \left(x - y\right)}{z}\\
\end{array}
\end{array}
if x < -1.39999999999999997e-56Initial program 98.5%
remove-double-neg98.5%
neg-mul-198.5%
times-frac100.0%
metadata-eval100.0%
div-sub99.9%
distribute-frac-neg299.9%
distribute-frac-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 86.4%
if -1.39999999999999997e-56 < x < 3.70000000000000009e-25Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 96.6%
if 3.70000000000000009e-25 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in z around 0 85.1%
associate-*r/85.1%
Simplified85.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.1e-55) (* -4.0 (- 0.5 (/ x z))) (if (<= x 3.7e-25) (* -4.0 (+ 0.5 (/ y z))) (* (- x y) (/ 4.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.1e-55) {
tmp = -4.0 * (0.5 - (x / z));
} else if (x <= 3.7e-25) {
tmp = -4.0 * (0.5 + (y / z));
} else {
tmp = (x - y) * (4.0 / z);
}
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.1d-55)) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else if (x <= 3.7d-25) then
tmp = (-4.0d0) * (0.5d0 + (y / z))
else
tmp = (x - y) * (4.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.1e-55) {
tmp = -4.0 * (0.5 - (x / z));
} else if (x <= 3.7e-25) {
tmp = -4.0 * (0.5 + (y / z));
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.1e-55: tmp = -4.0 * (0.5 - (x / z)) elif x <= 3.7e-25: tmp = -4.0 * (0.5 + (y / z)) else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.1e-55) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); elseif (x <= 3.7e-25) tmp = Float64(-4.0 * Float64(0.5 + Float64(y / z))); else tmp = Float64(Float64(x - y) * Float64(4.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.1e-55) tmp = -4.0 * (0.5 - (x / z)); elseif (x <= 3.7e-25) tmp = -4.0 * (0.5 + (y / z)); else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.1e-55], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e-25], N[(-4.0 * N[(0.5 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-55}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-25}:\\
\;\;\;\;-4 \cdot \left(0.5 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if x < -1.1e-55Initial program 98.5%
remove-double-neg98.5%
neg-mul-198.5%
times-frac100.0%
metadata-eval100.0%
div-sub99.9%
distribute-frac-neg299.9%
distribute-frac-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 86.4%
if -1.1e-55 < x < 3.70000000000000009e-25Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 96.6%
if 3.70000000000000009e-25 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in z around 0 85.1%
associate-*r/85.1%
Simplified85.1%
Taylor expanded in x around 0 81.2%
fma-define81.2%
remove-double-neg81.2%
distribute-frac-neg281.2%
distribute-frac-neg81.2%
fma-define81.2%
associate-/l*81.2%
*-commutative81.2%
associate-/l*81.1%
neg-mul-181.1%
associate-/r*81.1%
metadata-eval81.1%
metadata-eval81.1%
associate-*r/81.1%
*-commutative81.1%
associate-*l/81.1%
associate-*r/80.8%
metadata-eval80.8%
associate-*r/80.8%
distribute-rgt-in84.7%
associate-*r/84.7%
metadata-eval84.7%
+-commutative84.7%
sub-neg84.7%
Simplified84.7%
Final simplification90.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.95e+66) -2.0 (if (<= z 2.6e+186) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.95e+66) {
tmp = -2.0;
} else if (z <= 2.6e+186) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.95d+66)) then
tmp = -2.0d0
else if (z <= 2.6d+186) then
tmp = (-4.0d0) * (y / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.95e+66) {
tmp = -2.0;
} else if (z <= 2.6e+186) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.95e+66: tmp = -2.0 elif z <= 2.6e+186: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.95e+66) tmp = -2.0; elseif (z <= 2.6e+186) tmp = Float64(-4.0 * Float64(y / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.95e+66) tmp = -2.0; elseif (z <= 2.6e+186) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.95e+66], -2.0, If[LessEqual[z, 2.6e+186], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{+66}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+186}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.9500000000000002e66 or 2.6000000000000001e186 < z Initial program 98.8%
*-commutative98.8%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 71.7%
if -1.9500000000000002e66 < z < 2.6000000000000001e186Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 42.7%
*-commutative42.7%
Simplified42.7%
Final simplification51.7%
(FPCore (x y z) :precision binary64 (if (<= z -4.1e+65) -2.0 (if (<= z 2.6e+186) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.1e+65) {
tmp = -2.0;
} else if (z <= 2.6e+186) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-4.1d+65)) then
tmp = -2.0d0
else if (z <= 2.6d+186) then
tmp = y * ((-4.0d0) / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.1e+65) {
tmp = -2.0;
} else if (z <= 2.6e+186) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.1e+65: tmp = -2.0 elif z <= 2.6e+186: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.1e+65) tmp = -2.0; elseif (z <= 2.6e+186) tmp = Float64(y * Float64(-4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.1e+65) tmp = -2.0; elseif (z <= 2.6e+186) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.1e+65], -2.0, If[LessEqual[z, 2.6e+186], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+65}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+186}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.1000000000000001e65 or 2.6000000000000001e186 < z Initial program 98.8%
*-commutative98.8%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 71.7%
if -4.1000000000000001e65 < z < 2.6000000000000001e186Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 88.7%
associate-*r/88.7%
Simplified88.7%
Taylor expanded in x around 0 42.7%
associate-*r/42.7%
*-commutative42.7%
associate-*r/42.6%
Simplified42.6%
(FPCore (x y z) :precision binary64 -2.0)
double code(double x, double y, double z) {
return -2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -2.0d0
end function
public static double code(double x, double y, double z) {
return -2.0;
}
def code(x, y, z): return -2.0
function code(x, y, z) return -2.0 end
function tmp = code(x, y, z) tmp = -2.0; end
code[x_, y_, z_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 99.6%
*-commutative99.6%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 31.1%
(FPCore (x y z) :precision binary64 (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z)))))
double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
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)) - (2.0d0 + (4.0d0 * (y / z)))
end function
public static double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
def code(x, y, z): return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)))
function code(x, y, z) return Float64(Float64(4.0 * Float64(x / z)) - Float64(2.0 + Float64(4.0 * Float64(y / z)))) end
function tmp = code(x, y, z) tmp = (4.0 * (x / z)) - (2.0 + (4.0 * (y / z))); end
code[x_, y_, z_] := N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 + N[(4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)
\end{array}
herbie shell --seed 2024100
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))