
(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 7 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 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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x 4.0) z)) (t_1 (* -4.0 (/ y z))))
(if (<= x -3.2e+110)
t_0
(if (<= x -1.1e-63)
t_1
(if (<= x -1.8e-137)
-2.0
(if (<= x 9e-138) t_1 (if (<= x 5.6e+35) -2.0 t_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 (x <= -3.2e+110) {
tmp = t_0;
} else if (x <= -1.1e-63) {
tmp = t_1;
} else if (x <= -1.8e-137) {
tmp = -2.0;
} else if (x <= 9e-138) {
tmp = t_1;
} else if (x <= 5.6e+35) {
tmp = -2.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) :: t_1
real(8) :: tmp
t_0 = (x * 4.0d0) / z
t_1 = (-4.0d0) * (y / z)
if (x <= (-3.2d+110)) then
tmp = t_0
else if (x <= (-1.1d-63)) then
tmp = t_1
else if (x <= (-1.8d-137)) then
tmp = -2.0d0
else if (x <= 9d-138) then
tmp = t_1
else if (x <= 5.6d+35) then
tmp = -2.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) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -3.2e+110) {
tmp = t_0;
} else if (x <= -1.1e-63) {
tmp = t_1;
} else if (x <= -1.8e-137) {
tmp = -2.0;
} else if (x <= 9e-138) {
tmp = t_1;
} else if (x <= 5.6e+35) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 4.0) / z t_1 = -4.0 * (y / z) tmp = 0 if x <= -3.2e+110: tmp = t_0 elif x <= -1.1e-63: tmp = t_1 elif x <= -1.8e-137: tmp = -2.0 elif x <= 9e-138: tmp = t_1 elif x <= 5.6e+35: tmp = -2.0 else: tmp = t_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 (x <= -3.2e+110) tmp = t_0; elseif (x <= -1.1e-63) tmp = t_1; elseif (x <= -1.8e-137) tmp = -2.0; elseif (x <= 9e-138) tmp = t_1; elseif (x <= 5.6e+35) tmp = -2.0; else tmp = t_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 (x <= -3.2e+110) tmp = t_0; elseif (x <= -1.1e-63) tmp = t_1; elseif (x <= -1.8e-137) tmp = -2.0; elseif (x <= 9e-138) tmp = t_1; elseif (x <= 5.6e+35) tmp = -2.0; else tmp = t_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[x, -3.2e+110], t$95$0, If[LessEqual[x, -1.1e-63], t$95$1, If[LessEqual[x, -1.8e-137], -2.0, If[LessEqual[x, 9e-138], t$95$1, If[LessEqual[x, 5.6e+35], -2.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -3.2 \cdot 10^{+110}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-63}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-137}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-138}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+35}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.19999999999999994e110 or 5.59999999999999997e35 < x 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 x around inf 75.1%
*-commutative75.1%
associate-*l/75.1%
Simplified75.1%
if -3.19999999999999994e110 < x < -1.1e-63 or -1.80000000000000003e-137 < x < 9.00000000000000016e-138Initial 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 inf 54.0%
*-commutative54.0%
Simplified54.0%
if -1.1e-63 < x < -1.80000000000000003e-137 or 9.00000000000000016e-138 < x < 5.59999999999999997e35Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
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.8%
Final simplification63.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.5e+72) (not (<= x 2e+42))) (* 4.0 (+ -0.5 (/ x z))) (+ (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.5e+72) || !(x <= 2e+42)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = (-4.0 * (y / z)) + -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 ((x <= (-1.5d+72)) .or. (.not. (x <= 2d+42))) then
tmp = 4.0d0 * ((-0.5d0) + (x / z))
else
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.5e+72) || !(x <= 2e+42)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = (-4.0 * (y / z)) + -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.5e+72) or not (x <= 2e+42): tmp = 4.0 * (-0.5 + (x / z)) else: tmp = (-4.0 * (y / z)) + -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.5e+72) || !(x <= 2e+42)) tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); else tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.5e+72) || ~((x <= 2e+42))) tmp = 4.0 * (-0.5 + (x / z)); else tmp = (-4.0 * (y / z)) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.5e+72], N[Not[LessEqual[x, 2e+42]], $MachinePrecision]], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+72} \lor \neg \left(x \leq 2 \cdot 10^{+42}\right):\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\end{array}
\end{array}
if x < -1.50000000000000001e72 or 2.00000000000000009e42 < x 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 y around 0 88.3%
sub-neg88.3%
+-commutative88.3%
neg-sub088.3%
associate-+l-88.3%
neg-sub088.3%
neg-mul-188.3%
associate-*r*88.3%
metadata-eval88.3%
sub-neg88.3%
metadata-eval88.3%
Simplified88.3%
if -1.50000000000000001e72 < x < 2.00000000000000009e42Initial 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 91.1%
+-commutative91.1%
distribute-rgt-in91.1%
metadata-eval91.1%
Simplified91.1%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.2e+104) (not (<= z 1.76e-50))) (* 4.0 (+ -0.5 (/ x z))) (* -4.0 (/ (- y x) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.2e+104) || !(z <= 1.76e-50)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = -4.0 * ((y - 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 ((z <= (-4.2d+104)) .or. (.not. (z <= 1.76d-50))) then
tmp = 4.0d0 * ((-0.5d0) + (x / z))
else
tmp = (-4.0d0) * ((y - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.2e+104) || !(z <= 1.76e-50)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = -4.0 * ((y - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.2e+104) or not (z <= 1.76e-50): tmp = 4.0 * (-0.5 + (x / z)) else: tmp = -4.0 * ((y - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.2e+104) || !(z <= 1.76e-50)) tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); else tmp = Float64(-4.0 * Float64(Float64(y - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.2e+104) || ~((z <= 1.76e-50))) tmp = 4.0 * (-0.5 + (x / z)); else tmp = -4.0 * ((y - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.2e+104], N[Not[LessEqual[z, 1.76e-50]], $MachinePrecision]], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+104} \lor \neg \left(z \leq 1.76 \cdot 10^{-50}\right):\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\
\end{array}
\end{array}
if z < -4.1999999999999997e104 or 1.76e-50 < 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 y around 0 83.1%
sub-neg83.1%
+-commutative83.1%
neg-sub083.1%
associate-+l-83.1%
neg-sub083.1%
neg-mul-183.1%
associate-*r*83.1%
metadata-eval83.1%
sub-neg83.1%
metadata-eval83.1%
Simplified83.1%
if -4.1999999999999997e104 < z < 1.76e-50Initial 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 0 89.4%
*-commutative89.4%
Simplified89.4%
Final simplification86.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -6e+111) (not (<= y 3.4e+57))) (* -4.0 (/ y z)) (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+111) || !(y <= 3.4e+57)) {
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 <= (-6d+111)) .or. (.not. (y <= 3.4d+57))) 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 <= -6e+111) || !(y <= 3.4e+57)) {
tmp = -4.0 * (y / z);
} else {
tmp = 4.0 * (-0.5 + (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6e+111) or not (y <= 3.4e+57): 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 <= -6e+111) || !(y <= 3.4e+57)) 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 <= -6e+111) || ~((y <= 3.4e+57))) 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, -6e+111], N[Not[LessEqual[y, 3.4e+57]], $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 -6 \cdot 10^{+111} \lor \neg \left(y \leq 3.4 \cdot 10^{+57}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -6e111 or 3.39999999999999992e57 < y 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 y around inf 76.6%
*-commutative76.6%
Simplified76.6%
if -6e111 < y < 3.39999999999999992e57Initial 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 85.8%
sub-neg85.8%
+-commutative85.8%
neg-sub085.8%
associate-+l-85.8%
neg-sub085.8%
neg-mul-185.8%
associate-*r*85.8%
metadata-eval85.8%
sub-neg85.8%
metadata-eval85.8%
Simplified85.8%
Final simplification82.8%
(FPCore (x y z) :precision binary64 (if (<= z -4.2e+104) -2.0 (if (<= z 1.76e-50) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e+104) {
tmp = -2.0;
} else if (z <= 1.76e-50) {
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 <= (-4.2d+104)) then
tmp = -2.0d0
else if (z <= 1.76d-50) 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 <= -4.2e+104) {
tmp = -2.0;
} else if (z <= 1.76e-50) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.2e+104: tmp = -2.0 elif z <= 1.76e-50: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.2e+104) tmp = -2.0; elseif (z <= 1.76e-50) 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 <= -4.2e+104) tmp = -2.0; elseif (z <= 1.76e-50) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.2e+104], -2.0, If[LessEqual[z, 1.76e-50], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+104}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.76 \cdot 10^{-50}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.1999999999999997e104 or 1.76e-50 < 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 61.3%
if -4.1999999999999997e104 < z < 1.76e-50Initial 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 inf 52.2%
*-commutative52.2%
Simplified52.2%
Final simplification56.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 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 35.6%
(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 2024186
(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))