
(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 8 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 (* -4.0 (/ y z))))
(if (<= z -2.55e+125)
-2.0
(if (<= z -260000.0)
t_0
(if (<= z -3.4e-199) (/ (* x 4.0) z) (if (<= z 5e+100) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (z <= -2.55e+125) {
tmp = -2.0;
} else if (z <= -260000.0) {
tmp = t_0;
} else if (z <= -3.4e-199) {
tmp = (x * 4.0) / z;
} else if (z <= 5e+100) {
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) :: tmp
t_0 = (-4.0d0) * (y / z)
if (z <= (-2.55d+125)) then
tmp = -2.0d0
else if (z <= (-260000.0d0)) then
tmp = t_0
else if (z <= (-3.4d-199)) then
tmp = (x * 4.0d0) / z
else if (z <= 5d+100) 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 = -4.0 * (y / z);
double tmp;
if (z <= -2.55e+125) {
tmp = -2.0;
} else if (z <= -260000.0) {
tmp = t_0;
} else if (z <= -3.4e-199) {
tmp = (x * 4.0) / z;
} else if (z <= 5e+100) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if z <= -2.55e+125: tmp = -2.0 elif z <= -260000.0: tmp = t_0 elif z <= -3.4e-199: tmp = (x * 4.0) / z elif z <= 5e+100: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (z <= -2.55e+125) tmp = -2.0; elseif (z <= -260000.0) tmp = t_0; elseif (z <= -3.4e-199) tmp = Float64(Float64(x * 4.0) / z); elseif (z <= 5e+100) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); tmp = 0.0; if (z <= -2.55e+125) tmp = -2.0; elseif (z <= -260000.0) tmp = t_0; elseif (z <= -3.4e-199) tmp = (x * 4.0) / z; elseif (z <= 5e+100) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.55e+125], -2.0, If[LessEqual[z, -260000.0], t$95$0, If[LessEqual[z, -3.4e-199], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 5e+100], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -2.55 \cdot 10^{+125}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -260000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.4 \cdot 10^{-199}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.5499999999999999e125 or 4.9999999999999999e100 < z Initial 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 z around inf 78.6%
if -2.5499999999999999e125 < z < -2.6e5 or -3.40000000000000006e-199 < z < 4.9999999999999999e100Initial 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 y around inf 55.4%
*-commutative55.4%
Simplified55.4%
if -2.6e5 < z < -3.40000000000000006e-199Initial program 100.0%
Taylor expanded in x around inf 54.7%
*-commutative54.7%
Simplified54.7%
Final simplification62.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))))
(if (<= z -4.5e+125)
-2.0
(if (<= z -780000.0)
t_0
(if (<= z -2.6e-196) (* x (/ 4.0 z)) (if (<= z 4.5e+100) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (z <= -4.5e+125) {
tmp = -2.0;
} else if (z <= -780000.0) {
tmp = t_0;
} else if (z <= -2.6e-196) {
tmp = x * (4.0 / z);
} else if (z <= 4.5e+100) {
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) :: tmp
t_0 = (-4.0d0) * (y / z)
if (z <= (-4.5d+125)) then
tmp = -2.0d0
else if (z <= (-780000.0d0)) then
tmp = t_0
else if (z <= (-2.6d-196)) then
tmp = x * (4.0d0 / z)
else if (z <= 4.5d+100) 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 = -4.0 * (y / z);
double tmp;
if (z <= -4.5e+125) {
tmp = -2.0;
} else if (z <= -780000.0) {
tmp = t_0;
} else if (z <= -2.6e-196) {
tmp = x * (4.0 / z);
} else if (z <= 4.5e+100) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if z <= -4.5e+125: tmp = -2.0 elif z <= -780000.0: tmp = t_0 elif z <= -2.6e-196: tmp = x * (4.0 / z) elif z <= 4.5e+100: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (z <= -4.5e+125) tmp = -2.0; elseif (z <= -780000.0) tmp = t_0; elseif (z <= -2.6e-196) tmp = Float64(x * Float64(4.0 / z)); elseif (z <= 4.5e+100) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); tmp = 0.0; if (z <= -4.5e+125) tmp = -2.0; elseif (z <= -780000.0) tmp = t_0; elseif (z <= -2.6e-196) tmp = x * (4.0 / z); elseif (z <= 4.5e+100) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.5e+125], -2.0, If[LessEqual[z, -780000.0], t$95$0, If[LessEqual[z, -2.6e-196], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.5e+100], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -4.5 \cdot 10^{+125}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -780000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.6 \cdot 10^{-196}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.5e125 or 4.50000000000000036e100 < z Initial 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 z around inf 78.6%
if -4.5e125 < z < -7.8e5 or -2.5999999999999998e-196 < z < 4.50000000000000036e100Initial 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 y around inf 55.4%
*-commutative55.4%
Simplified55.4%
if -7.8e5 < z < -2.5999999999999998e-196Initial 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 inf 54.7%
associate-*r/54.7%
*-commutative54.7%
associate-*r/54.4%
Simplified54.4%
Final simplification62.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ -4.0 z))))
(if (<= z -1.42e+125)
-2.0
(if (<= z -110000000000.0)
t_0
(if (<= z -8e-199) (* x (/ 4.0 z)) (if (<= z 1.4e+110) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = y * (-4.0 / z);
double tmp;
if (z <= -1.42e+125) {
tmp = -2.0;
} else if (z <= -110000000000.0) {
tmp = t_0;
} else if (z <= -8e-199) {
tmp = x * (4.0 / z);
} else if (z <= 1.4e+110) {
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) :: tmp
t_0 = y * ((-4.0d0) / z)
if (z <= (-1.42d+125)) then
tmp = -2.0d0
else if (z <= (-110000000000.0d0)) then
tmp = t_0
else if (z <= (-8d-199)) then
tmp = x * (4.0d0 / z)
else if (z <= 1.4d+110) 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 = y * (-4.0 / z);
double tmp;
if (z <= -1.42e+125) {
tmp = -2.0;
} else if (z <= -110000000000.0) {
tmp = t_0;
} else if (z <= -8e-199) {
tmp = x * (4.0 / z);
} else if (z <= 1.4e+110) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (-4.0 / z) tmp = 0 if z <= -1.42e+125: tmp = -2.0 elif z <= -110000000000.0: tmp = t_0 elif z <= -8e-199: tmp = x * (4.0 / z) elif z <= 1.4e+110: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(-4.0 / z)) tmp = 0.0 if (z <= -1.42e+125) tmp = -2.0; elseif (z <= -110000000000.0) tmp = t_0; elseif (z <= -8e-199) tmp = Float64(x * Float64(4.0 / z)); elseif (z <= 1.4e+110) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (-4.0 / z); tmp = 0.0; if (z <= -1.42e+125) tmp = -2.0; elseif (z <= -110000000000.0) tmp = t_0; elseif (z <= -8e-199) tmp = x * (4.0 / z); elseif (z <= 1.4e+110) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.42e+125], -2.0, If[LessEqual[z, -110000000000.0], t$95$0, If[LessEqual[z, -8e-199], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.4e+110], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{-4}{z}\\
\mathbf{if}\;z \leq -1.42 \cdot 10^{+125}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -110000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-199}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+110}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.4200000000000001e125 or 1.39999999999999993e110 < z Initial 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 z around inf 78.6%
if -1.4200000000000001e125 < z < -1.1e11 or -7.99999999999999986e-199 < z < 1.39999999999999993e110Initial 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 inf 55.8%
associate-*r/55.1%
*-commutative55.1%
associate-/l*55.7%
Simplified55.7%
if -1.1e11 < z < -7.99999999999999986e-199Initial 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 inf 53.4%
associate-*r/53.4%
*-commutative53.4%
associate-*r/53.2%
Simplified53.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.2e-18) (not (<= y 2.9e-71))) (+ -2.0 (* -4.0 (/ y z))) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e-18) || !(y <= 2.9e-71)) {
tmp = -2.0 + (-4.0 * (y / z));
} else {
tmp = -4.0 * (0.5 - (x / 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 ((y <= (-1.2d-18)) .or. (.not. (y <= 2.9d-71))) then
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e-18) || !(y <= 2.9e-71)) {
tmp = -2.0 + (-4.0 * (y / z));
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.2e-18) or not (y <= 2.9e-71): tmp = -2.0 + (-4.0 * (y / z)) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.2e-18) || !(y <= 2.9e-71)) tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.2e-18) || ~((y <= 2.9e-71))) tmp = -2.0 + (-4.0 * (y / z)); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.2e-18], N[Not[LessEqual[y, 2.9e-71]], $MachinePrecision]], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{-18} \lor \neg \left(y \leq 2.9 \cdot 10^{-71}\right):\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.19999999999999997e-18 or 2.8999999999999999e-71 < y Initial 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 86.3%
distribute-rgt-in86.3%
metadata-eval86.3%
Simplified86.3%
if -1.19999999999999997e-18 < y < 2.8999999999999999e-71Initial 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 y around 0 91.6%
*-commutative91.6%
Simplified91.6%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.15e+81) (not (<= y 0.0052))) (* -4.0 (/ y z)) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.15e+81) || !(y <= 0.0052)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / 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 ((y <= (-1.15d+81)) .or. (.not. (y <= 0.0052d0))) then
tmp = (-4.0d0) * (y / z)
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.15e+81) || !(y <= 0.0052)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.15e+81) or not (y <= 0.0052): tmp = -4.0 * (y / z) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.15e+81) || !(y <= 0.0052)) tmp = Float64(-4.0 * Float64(y / z)); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.15e+81) || ~((y <= 0.0052))) tmp = -4.0 * (y / z); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.15e+81], N[Not[LessEqual[y, 0.0052]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+81} \lor \neg \left(y \leq 0.0052\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.1499999999999999e81 or 0.0051999999999999998 < y Initial program 99.0%
remove-double-neg99.0%
neg-mul-199.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 y around inf 75.0%
*-commutative75.0%
Simplified75.0%
if -1.1499999999999999e81 < y < 0.0051999999999999998Initial 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 y around 0 84.4%
*-commutative84.4%
Simplified84.4%
Final simplification81.0%
(FPCore (x y z) :precision binary64 (if (<= z -8.2e+35) -2.0 (if (<= z 105000.0) (* x (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.2e+35) {
tmp = -2.0;
} else if (z <= 105000.0) {
tmp = x * (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 <= (-8.2d+35)) then
tmp = -2.0d0
else if (z <= 105000.0d0) then
tmp = x * (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 <= -8.2e+35) {
tmp = -2.0;
} else if (z <= 105000.0) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.2e+35: tmp = -2.0 elif z <= 105000.0: tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.2e+35) tmp = -2.0; elseif (z <= 105000.0) tmp = Float64(x * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.2e+35) tmp = -2.0; elseif (z <= 105000.0) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.2e+35], -2.0, If[LessEqual[z, 105000.0], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+35}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 105000:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -8.1999999999999997e35 or 105000 < z 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 z around inf 61.9%
if -8.1999999999999997e35 < z < 105000Initial 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 inf 44.8%
associate-*r/44.8%
*-commutative44.8%
associate-*r/44.7%
Simplified44.7%
(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%
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%
Taylor expanded in z around inf 35.2%
(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 2024145
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (* 4 (/ x z)) (+ 2 (* 4 (/ y z)))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))