
(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 (- (- 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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (/ (* y -4.0) z)))
(if (<= y -1.05e+47)
t_1
(if (<= y -5.8e-143)
-2.0
(if (<= y 1.75e-173)
t_0
(if (<= y 2.75e-132) -2.0 (if (<= y 9.5e+165) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = (y * -4.0) / z;
double tmp;
if (y <= -1.05e+47) {
tmp = t_1;
} else if (y <= -5.8e-143) {
tmp = -2.0;
} else if (y <= 1.75e-173) {
tmp = t_0;
} else if (y <= 2.75e-132) {
tmp = -2.0;
} else if (y <= 9.5e+165) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = 4.0d0 * (x / z)
t_1 = (y * (-4.0d0)) / z
if (y <= (-1.05d+47)) then
tmp = t_1
else if (y <= (-5.8d-143)) then
tmp = -2.0d0
else if (y <= 1.75d-173) then
tmp = t_0
else if (y <= 2.75d-132) then
tmp = -2.0d0
else if (y <= 9.5d+165) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = (y * -4.0) / z;
double tmp;
if (y <= -1.05e+47) {
tmp = t_1;
} else if (y <= -5.8e-143) {
tmp = -2.0;
} else if (y <= 1.75e-173) {
tmp = t_0;
} else if (y <= 2.75e-132) {
tmp = -2.0;
} else if (y <= 9.5e+165) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = (y * -4.0) / z tmp = 0 if y <= -1.05e+47: tmp = t_1 elif y <= -5.8e-143: tmp = -2.0 elif y <= 1.75e-173: tmp = t_0 elif y <= 2.75e-132: tmp = -2.0 elif y <= 9.5e+165: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(Float64(y * -4.0) / z) tmp = 0.0 if (y <= -1.05e+47) tmp = t_1; elseif (y <= -5.8e-143) tmp = -2.0; elseif (y <= 1.75e-173) tmp = t_0; elseif (y <= 2.75e-132) tmp = -2.0; elseif (y <= 9.5e+165) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); t_1 = (y * -4.0) / z; tmp = 0.0; if (y <= -1.05e+47) tmp = t_1; elseif (y <= -5.8e-143) tmp = -2.0; elseif (y <= 1.75e-173) tmp = t_0; elseif (y <= 2.75e-132) tmp = -2.0; elseif (y <= 9.5e+165) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y * -4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -1.05e+47], t$95$1, If[LessEqual[y, -5.8e-143], -2.0, If[LessEqual[y, 1.75e-173], t$95$0, If[LessEqual[y, 2.75e-132], -2.0, If[LessEqual[y, 9.5e+165], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := \frac{y \cdot -4}{z}\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{+47}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-143}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{-173}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.75 \cdot 10^{-132}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+165}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -1.05e47 or 9.50000000000000017e165 < y Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 77.2%
*-commutative77.2%
associate-*l/77.2%
Simplified77.2%
if -1.05e47 < y < -5.8000000000000002e-143 or 1.75000000000000007e-173 < y < 2.75e-132Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 76.5%
if -5.8000000000000002e-143 < y < 1.75000000000000007e-173 or 2.75e-132 < y < 9.50000000000000017e165Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 56.1%
Final simplification66.8%
(FPCore (x y z)
:precision binary64
(if (<= y -8.2e+48)
(* 4.0 (- -0.5 (/ y z)))
(if (or (<= y 12500000.0) (and (not (<= y 1.06e+57)) (<= y 4.2e+109)))
(+ (* 4.0 (/ x z)) -2.0)
(* (- x y) (/ 4.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+48) {
tmp = 4.0 * (-0.5 - (y / z));
} else if ((y <= 12500000.0) || (!(y <= 1.06e+57) && (y <= 4.2e+109))) {
tmp = (4.0 * (x / z)) + -2.0;
} 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 (y <= (-8.2d+48)) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else if ((y <= 12500000.0d0) .or. (.not. (y <= 1.06d+57)) .and. (y <= 4.2d+109)) then
tmp = (4.0d0 * (x / z)) + (-2.0d0)
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 (y <= -8.2e+48) {
tmp = 4.0 * (-0.5 - (y / z));
} else if ((y <= 12500000.0) || (!(y <= 1.06e+57) && (y <= 4.2e+109))) {
tmp = (4.0 * (x / z)) + -2.0;
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e+48: tmp = 4.0 * (-0.5 - (y / z)) elif (y <= 12500000.0) or (not (y <= 1.06e+57) and (y <= 4.2e+109)): tmp = (4.0 * (x / z)) + -2.0 else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e+48) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); elseif ((y <= 12500000.0) || (!(y <= 1.06e+57) && (y <= 4.2e+109))) tmp = Float64(Float64(4.0 * Float64(x / z)) + -2.0); 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 (y <= -8.2e+48) tmp = 4.0 * (-0.5 - (y / z)); elseif ((y <= 12500000.0) || (~((y <= 1.06e+57)) && (y <= 4.2e+109))) tmp = (4.0 * (x / z)) + -2.0; else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e+48], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 12500000.0], And[N[Not[LessEqual[y, 1.06e+57]], $MachinePrecision], LessEqual[y, 4.2e+109]]], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+48}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{elif}\;y \leq 12500000 \lor \neg \left(y \leq 1.06 \cdot 10^{+57}\right) \land y \leq 4.2 \cdot 10^{+109}:\\
\;\;\;\;4 \cdot \frac{x}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if y < -8.2000000000000005e48Initial program 100.0%
associate-*l/99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 85.3%
div-sub85.3%
*-commutative85.3%
*-lft-identity85.3%
associate-*l/85.2%
associate-*r*85.2%
lft-mult-inverse85.3%
metadata-eval85.3%
Simplified85.3%
if -8.2000000000000005e48 < y < 1.25e7 or 1.06e57 < y < 4.2000000000000003e109Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 95.5%
metadata-eval95.5%
cancel-sign-sub-inv95.5%
div-sub95.5%
sub-neg95.5%
associate-/l*95.5%
*-lft-identity95.5%
associate-*l/95.4%
lft-mult-inverse95.5%
metadata-eval95.5%
metadata-eval95.5%
distribute-lft-in95.5%
metadata-eval95.5%
Simplified95.5%
if 1.25e7 < y < 1.06e57 or 4.2000000000000003e109 < y Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 93.8%
associate-*r/93.8%
associate-*l/93.6%
*-commutative93.6%
Simplified93.6%
Final simplification93.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.15e+83) (not (<= x 3.6e+82))) (* 4.0 (/ x z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.15e+83) || !(x <= 3.6e+82)) {
tmp = 4.0 * (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 <= (-2.15d+83)) .or. (.not. (x <= 3.6d+82))) then
tmp = 4.0d0 * (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 <= -2.15e+83) || !(x <= 3.6e+82)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.15e+83) or not (x <= 3.6e+82): tmp = 4.0 * (x / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.15e+83) || !(x <= 3.6e+82)) tmp = Float64(4.0 * 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 <= -2.15e+83) || ~((x <= 3.6e+82))) tmp = 4.0 * (x / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.15e+83], N[Not[LessEqual[x, 3.6e+82]], $MachinePrecision]], N[(4.0 * N[(x / z), $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.15 \cdot 10^{+83} \lor \neg \left(x \leq 3.6 \cdot 10^{+82}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -2.15e83 or 3.60000000000000014e82 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 77.7%
if -2.15e83 < x < 3.60000000000000014e82Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 87.6%
div-sub87.6%
*-commutative87.6%
*-lft-identity87.6%
associate-*l/87.4%
associate-*r*87.4%
lft-mult-inverse87.6%
metadata-eval87.6%
Simplified87.6%
Final simplification83.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.6e+35) (not (<= x 7.4e+33))) (* (- x y) (/ 4.0 z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.6e+35) || !(x <= 7.4e+33)) {
tmp = (x - y) * (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 <= (-5.6d+35)) .or. (.not. (x <= 7.4d+33))) then
tmp = (x - y) * (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 <= -5.6e+35) || !(x <= 7.4e+33)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.6e+35) or not (x <= 7.4e+33): tmp = (x - y) * (4.0 / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.6e+35) || !(x <= 7.4e+33)) tmp = Float64(Float64(x - y) * Float64(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 <= -5.6e+35) || ~((x <= 7.4e+33))) tmp = (x - y) * (4.0 / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.6e+35], N[Not[LessEqual[x, 7.4e+33]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{+35} \lor \neg \left(x \leq 7.4 \cdot 10^{+33}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -5.59999999999999997e35 or 7.3999999999999997e33 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 83.3%
associate-*r/83.3%
associate-*l/83.1%
*-commutative83.1%
Simplified83.1%
if -5.59999999999999997e35 < x < 7.3999999999999997e33Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 90.6%
div-sub90.6%
*-commutative90.6%
*-lft-identity90.6%
associate-*l/90.5%
associate-*r*90.5%
lft-mult-inverse90.6%
metadata-eval90.6%
Simplified90.6%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (* 4.0 (- (+ -0.5 (/ x z)) (/ y z))))
double code(double x, double y, double z) {
return 4.0 * ((-0.5 + (x / z)) - (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 * (((-0.5d0) + (x / z)) - (y / z))
end function
public static double code(double x, double y, double z) {
return 4.0 * ((-0.5 + (x / z)) - (y / z));
}
def code(x, y, z): return 4.0 * ((-0.5 + (x / z)) - (y / z))
function code(x, y, z) return Float64(4.0 * Float64(Float64(-0.5 + Float64(x / z)) - Float64(y / z))) end
function tmp = code(x, y, z) tmp = 4.0 * ((-0.5 + (x / z)) - (y / z)); end
code[x_, y_, z_] := N[(4.0 * N[(N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \left(\left(-0.5 + \frac{x}{z}\right) - \frac{y}{z}\right)
\end{array}
Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 97.6%
distribute-lft-out97.6%
div-sub97.6%
associate-+r-97.6%
*-commutative97.6%
*-lft-identity97.6%
associate-*l/97.6%
associate-*r*97.6%
lft-mult-inverse97.6%
metadata-eval97.6%
+-commutative97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x y z) :precision binary64 (* (/ 4.0 z) (+ (- x y) (* z -0.5))))
double code(double x, double y, double z) {
return (4.0 / z) * ((x - y) + (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 / z) * ((x - y) + (z * (-0.5d0)))
end function
public static double code(double x, double y, double z) {
return (4.0 / z) * ((x - y) + (z * -0.5));
}
def code(x, y, z): return (4.0 / z) * ((x - y) + (z * -0.5))
function code(x, y, z) return Float64(Float64(4.0 / z) * Float64(Float64(x - y) + Float64(z * -0.5))) end
function tmp = code(x, y, z) tmp = (4.0 / z) * ((x - y) + (z * -0.5)); end
code[x_, y_, z_] := N[(N[(4.0 / z), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] + N[(z * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{4}{z} \cdot \left(\left(x - y\right) + z \cdot -0.5\right)
\end{array}
Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= z -4.4e+76) -2.0 (if (<= z 2.8e+55) (* 4.0 (/ x z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.4e+76) {
tmp = -2.0;
} else if (z <= 2.8e+55) {
tmp = 4.0 * (x / 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.4d+76)) then
tmp = -2.0d0
else if (z <= 2.8d+55) then
tmp = 4.0d0 * (x / 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.4e+76) {
tmp = -2.0;
} else if (z <= 2.8e+55) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.4e+76: tmp = -2.0 elif z <= 2.8e+55: tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.4e+76) tmp = -2.0; elseif (z <= 2.8e+55) tmp = Float64(4.0 * Float64(x / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.4e+76) tmp = -2.0; elseif (z <= 2.8e+55) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.4e+76], -2.0, If[LessEqual[z, 2.8e+55], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+76}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+55}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.4000000000000001e76 or 2.8000000000000001e55 < z Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 67.2%
if -4.4000000000000001e76 < z < 2.8000000000000001e55Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 50.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%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 33.4%
Final simplification33.4%
(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 2023271
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:herbie-target
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))