
(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 (- (- 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
(if (or (<= (- x y) -1e+35)
(not
(or (<= (- x y) -100000000000.0)
(and (not (<= (- x y) -1e-117)) (<= (- x y) 2e-124)))))
(* (- x y) (/ 4.0 z))
-2.0))
double code(double x, double y, double z) {
double tmp;
if (((x - y) <= -1e+35) || !(((x - y) <= -100000000000.0) || (!((x - y) <= -1e-117) && ((x - y) <= 2e-124)))) {
tmp = (x - 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 (((x - y) <= (-1d+35)) .or. (.not. ((x - y) <= (-100000000000.0d0)) .or. (.not. ((x - y) <= (-1d-117))) .and. ((x - y) <= 2d-124))) then
tmp = (x - 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 (((x - y) <= -1e+35) || !(((x - y) <= -100000000000.0) || (!((x - y) <= -1e-117) && ((x - y) <= 2e-124)))) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x - y) <= -1e+35) or not (((x - y) <= -100000000000.0) or (not ((x - y) <= -1e-117) and ((x - y) <= 2e-124))): tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(x - y) <= -1e+35) || !((Float64(x - y) <= -100000000000.0) || (!(Float64(x - y) <= -1e-117) && (Float64(x - y) <= 2e-124)))) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x - y) <= -1e+35) || ~((((x - y) <= -100000000000.0) || (~(((x - y) <= -1e-117)) && ((x - y) <= 2e-124))))) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(x - y), $MachinePrecision], -1e+35], N[Not[Or[LessEqual[N[(x - y), $MachinePrecision], -100000000000.0], And[N[Not[LessEqual[N[(x - y), $MachinePrecision], -1e-117]], $MachinePrecision], LessEqual[N[(x - y), $MachinePrecision], 2e-124]]]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - y \leq -1 \cdot 10^{+35} \lor \neg \left(x - y \leq -100000000000 \lor \neg \left(x - y \leq -1 \cdot 10^{-117}\right) \land x - y \leq 2 \cdot 10^{-124}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if (-.f64 x y) < -9.9999999999999997e34 or -1e11 < (-.f64 x y) < -1.00000000000000003e-117 or 1.99999999999999987e-124 < (-.f64 x 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 79.5%
if -9.9999999999999997e34 < (-.f64 x y) < -1e11 or -1.00000000000000003e-117 < (-.f64 x y) < 1.99999999999999987e-124Initial 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 90.8%
Final simplification80.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))) (t_1 (* 4.0 (/ x z))))
(if (<= y -1.9e+121)
t_0
(if (<= y -1.4e-271)
t_1
(if (<= y 3.2e-180) -2.0 (if (<= y 4.2e+70) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double t_1 = 4.0 * (x / z);
double tmp;
if (y <= -1.9e+121) {
tmp = t_0;
} else if (y <= -1.4e-271) {
tmp = t_1;
} else if (y <= 3.2e-180) {
tmp = -2.0;
} else if (y <= 4.2e+70) {
tmp = t_1;
} 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 = (-4.0d0) * (y / z)
t_1 = 4.0d0 * (x / z)
if (y <= (-1.9d+121)) then
tmp = t_0
else if (y <= (-1.4d-271)) then
tmp = t_1
else if (y <= 3.2d-180) then
tmp = -2.0d0
else if (y <= 4.2d+70) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double t_1 = 4.0 * (x / z);
double tmp;
if (y <= -1.9e+121) {
tmp = t_0;
} else if (y <= -1.4e-271) {
tmp = t_1;
} else if (y <= 3.2e-180) {
tmp = -2.0;
} else if (y <= 4.2e+70) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) t_1 = 4.0 * (x / z) tmp = 0 if y <= -1.9e+121: tmp = t_0 elif y <= -1.4e-271: tmp = t_1 elif y <= 3.2e-180: tmp = -2.0 elif y <= 4.2e+70: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) t_1 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (y <= -1.9e+121) tmp = t_0; elseif (y <= -1.4e-271) tmp = t_1; elseif (y <= 3.2e-180) tmp = -2.0; elseif (y <= 4.2e+70) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); t_1 = 4.0 * (x / z); tmp = 0.0; if (y <= -1.9e+121) tmp = t_0; elseif (y <= -1.4e-271) tmp = t_1; elseif (y <= 3.2e-180) tmp = -2.0; elseif (y <= 4.2e+70) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.9e+121], t$95$0, If[LessEqual[y, -1.4e-271], t$95$1, If[LessEqual[y, 3.2e-180], -2.0, If[LessEqual[y, 4.2e+70], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
t_1 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -1.9 \cdot 10^{+121}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.4 \cdot 10^{-271}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-180}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.9e121 or 4.20000000000000015e70 < 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 74.9%
if -1.9e121 < y < -1.3999999999999999e-271 or 3.20000000000000015e-180 < y < 4.20000000000000015e70Initial 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 57.8%
if -1.3999999999999999e-271 < y < 3.20000000000000015e-180Initial 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 69.0%
Final simplification65.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.5e-54) (not (<= z 2.05e+14))) (- (* -4.0 (/ y z)) 2.0) (* (- x y) (/ 4.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e-54) || !(z <= 2.05e+14)) {
tmp = (-4.0 * (y / 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 ((z <= (-4.5d-54)) .or. (.not. (z <= 2.05d+14))) then
tmp = ((-4.0d0) * (y / 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 ((z <= -4.5e-54) || !(z <= 2.05e+14)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.5e-54) or not (z <= 2.05e+14): tmp = (-4.0 * (y / z)) - 2.0 else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.5e-54) || !(z <= 2.05e+14)) tmp = Float64(Float64(-4.0 * Float64(y / 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 ((z <= -4.5e-54) || ~((z <= 2.05e+14))) tmp = (-4.0 * (y / z)) - 2.0; else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.5e-54], N[Not[LessEqual[z, 2.05e+14]], $MachinePrecision]], N[(N[(-4.0 * N[(y / 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}\;z \leq -4.5 \cdot 10^{-54} \lor \neg \left(z \leq 2.05 \cdot 10^{+14}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if z < -4.4999999999999998e-54 or 2.05e14 < z Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 81.9%
if -4.4999999999999998e-54 < z < 2.05e14Initial 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 92.4%
Final simplification87.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e+116) (not (<= y 1.5e+62))) (- (* -4.0 (/ y z)) 2.0) (- (* 4.0 (/ x z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+116) || !(y <= 1.5e+62)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (4.0 * (x / 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 ((y <= (-1.4d+116)) .or. (.not. (y <= 1.5d+62))) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else
tmp = (4.0d0 * (x / z)) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+116) || !(y <= 1.5e+62)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (4.0 * (x / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.4e+116) or not (y <= 1.5e+62): tmp = (-4.0 * (y / z)) - 2.0 else: tmp = (4.0 * (x / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e+116) || !(y <= 1.5e+62)) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); else tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.4e+116) || ~((y <= 1.5e+62))) tmp = (-4.0 * (y / z)) - 2.0; else tmp = (4.0 * (x / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e+116], N[Not[LessEqual[y, 1.5e+62]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+116} \lor \neg \left(y \leq 1.5 \cdot 10^{+62}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\end{array}
\end{array}
if y < -1.40000000000000002e116 or 1.5e62 < y Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.7%
fma-neg99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate-/r/99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in x around 0 89.5%
if -1.40000000000000002e116 < y < 1.5e62Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in y around 0 88.6%
Final simplification88.9%
(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 (or (<= y -5.5e+48) (not (<= y 2.05e-43))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+48) || !(y <= 2.05e-43)) {
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 ((y <= (-5.5d+48)) .or. (.not. (y <= 2.05d-43))) 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 ((y <= -5.5e+48) || !(y <= 2.05e-43)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+48) or not (y <= 2.05e-43): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+48) || !(y <= 2.05e-43)) 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 ((y <= -5.5e+48) || ~((y <= 2.05e-43))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+48], N[Not[LessEqual[y, 2.05e-43]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+48} \lor \neg \left(y \leq 2.05 \cdot 10^{-43}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -5.5000000000000002e48 or 2.0499999999999999e-43 < 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 60.2%
if -5.5000000000000002e48 < y < 2.0499999999999999e-43Initial 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 44.2%
Final simplification52.4%
(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 30.1%
Final simplification30.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 2023318
(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))