
(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 (fma 4.0 (/ (- x y) z) -2.0))
double code(double x, double y, double z) {
return fma(4.0, ((x - y) / z), -2.0);
}
function code(x, y, z) return fma(4.0, Float64(Float64(x - y) / z), -2.0) end
code[x_, y_, z_] := N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, \frac{x - y}{z}, -2\right)
\end{array}
Initial program 99.2%
associate-*l/99.7%
sub-neg99.7%
distribute-lft-in99.8%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
associate-*r*99.2%
remove-double-neg99.2%
neg-mul-199.2%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (- -0.5 (/ y z)))))
(if (<= y -2.25e+60)
t_0
(if (<= y -2.05e-36)
(* 4.0 (/ (- x y) z))
(if (<= y 1.35e+41) (+ -2.0 (* 4.0 (/ x z))) t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (-0.5 - (y / z));
double tmp;
if (y <= -2.25e+60) {
tmp = t_0;
} else if (y <= -2.05e-36) {
tmp = 4.0 * ((x - y) / z);
} else if (y <= 1.35e+41) {
tmp = -2.0 + (4.0 * (x / z));
} 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) :: tmp
t_0 = 4.0d0 * ((-0.5d0) - (y / z))
if (y <= (-2.25d+60)) then
tmp = t_0
else if (y <= (-2.05d-36)) then
tmp = 4.0d0 * ((x - y) / z)
else if (y <= 1.35d+41) then
tmp = (-2.0d0) + (4.0d0 * (x / z))
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 * (-0.5 - (y / z));
double tmp;
if (y <= -2.25e+60) {
tmp = t_0;
} else if (y <= -2.05e-36) {
tmp = 4.0 * ((x - y) / z);
} else if (y <= 1.35e+41) {
tmp = -2.0 + (4.0 * (x / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (-0.5 - (y / z)) tmp = 0 if y <= -2.25e+60: tmp = t_0 elif y <= -2.05e-36: tmp = 4.0 * ((x - y) / z) elif y <= 1.35e+41: tmp = -2.0 + (4.0 * (x / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(-0.5 - Float64(y / z))) tmp = 0.0 if (y <= -2.25e+60) tmp = t_0; elseif (y <= -2.05e-36) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); elseif (y <= 1.35e+41) tmp = Float64(-2.0 + Float64(4.0 * Float64(x / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (-0.5 - (y / z)); tmp = 0.0; if (y <= -2.25e+60) tmp = t_0; elseif (y <= -2.05e-36) tmp = 4.0 * ((x - y) / z); elseif (y <= 1.35e+41) tmp = -2.0 + (4.0 * (x / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.25e+60], t$95$0, If[LessEqual[y, -2.05e-36], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+41], N[(-2.0 + N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{if}\;y \leq -2.25 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.05 \cdot 10^{-36}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+41}:\\
\;\;\;\;-2 + 4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.25000000000000006e60 or 1.35e41 < y Initial program 99.1%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 88.8%
div-sub88.8%
*-commutative88.8%
*-lft-identity88.8%
associate-*l/88.7%
associate-*r*88.7%
lft-mult-inverse88.8%
metadata-eval88.8%
Simplified88.8%
if -2.25000000000000006e60 < y < -2.05000000000000006e-36Initial 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 87.0%
if -2.05000000000000006e-36 < y < 1.35e41Initial program 99.2%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 90.8%
+-commutative90.8%
metadata-eval90.8%
cancel-sign-sub-inv90.8%
div-sub90.8%
sub-neg90.8%
associate-/l*90.8%
*-rgt-identity90.8%
*-commutative90.8%
associate-*l/90.7%
lft-mult-inverse90.8%
metadata-eval90.8%
metadata-eval90.8%
distribute-lft-in90.8%
metadata-eval90.8%
Simplified90.8%
Final simplification89.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))))
(if (<= x -1.96e-25)
t_0
(if (<= x 1.75e-9) (/ (* y -4.0) z) (if (<= x 3.5e+92) -2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double tmp;
if (x <= -1.96e-25) {
tmp = t_0;
} else if (x <= 1.75e-9) {
tmp = (y * -4.0) / z;
} else if (x <= 3.5e+92) {
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) :: tmp
t_0 = 4.0d0 * (x / z)
if (x <= (-1.96d-25)) then
tmp = t_0
else if (x <= 1.75d-9) then
tmp = (y * (-4.0d0)) / z
else if (x <= 3.5d+92) 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 = 4.0 * (x / z);
double tmp;
if (x <= -1.96e-25) {
tmp = t_0;
} else if (x <= 1.75e-9) {
tmp = (y * -4.0) / z;
} else if (x <= 3.5e+92) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) tmp = 0 if x <= -1.96e-25: tmp = t_0 elif x <= 1.75e-9: tmp = (y * -4.0) / z elif x <= 3.5e+92: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (x <= -1.96e-25) tmp = t_0; elseif (x <= 1.75e-9) tmp = Float64(Float64(y * -4.0) / z); elseif (x <= 3.5e+92) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); tmp = 0.0; if (x <= -1.96e-25) tmp = t_0; elseif (x <= 1.75e-9) tmp = (y * -4.0) / z; elseif (x <= 3.5e+92) tmp = -2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.96e-25], t$95$0, If[LessEqual[x, 1.75e-9], N[(N[(y * -4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 3.5e+92], -2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;x \leq -1.96 \cdot 10^{-25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-9}:\\
\;\;\;\;\frac{y \cdot -4}{z}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+92}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.96e-25 or 3.49999999999999986e92 < x Initial program 99.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 62.3%
if -1.96e-25 < x < 1.75e-9Initial program 99.2%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 51.1%
*-commutative51.1%
associate-*l/51.1%
Simplified51.1%
if 1.75e-9 < x < 3.49999999999999986e92Initial 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 49.8%
Final simplification55.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.8e+70) (not (<= x 2.9e+141))) (* 4.0 (/ x z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e+70) || !(x <= 2.9e+141)) {
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 <= (-3.8d+70)) .or. (.not. (x <= 2.9d+141))) 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 <= -3.8e+70) || !(x <= 2.9e+141)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.8e+70) or not (x <= 2.9e+141): 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 <= -3.8e+70) || !(x <= 2.9e+141)) 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 <= -3.8e+70) || ~((x <= 2.9e+141))) 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, -3.8e+70], N[Not[LessEqual[x, 2.9e+141]], $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 -3.8 \cdot 10^{+70} \lor \neg \left(x \leq 2.9 \cdot 10^{+141}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -3.7999999999999998e70 or 2.90000000000000007e141 < x Initial program 98.6%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 74.6%
if -3.7999999999999998e70 < x < 2.90000000000000007e141Initial program 99.5%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 82.8%
div-sub82.8%
*-commutative82.8%
*-lft-identity82.8%
associate-*l/82.7%
associate-*r*82.7%
lft-mult-inverse82.8%
metadata-eval82.8%
Simplified82.8%
Final simplification80.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.175) (not (<= z 1.1e+119))) (* 4.0 (- -0.5 (/ y z))) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.175) || !(z <= 1.1e+119)) {
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 ((z <= (-0.175d0)) .or. (.not. (z <= 1.1d+119))) 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 ((z <= -0.175) || !(z <= 1.1e+119)) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.175) or not (z <= 1.1e+119): 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 ((z <= -0.175) || !(z <= 1.1e+119)) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); else tmp = Float64(4.0 * Float64(Float64(x - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.175) || ~((z <= 1.1e+119))) tmp = 4.0 * (-0.5 - (y / z)); else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.175], N[Not[LessEqual[z, 1.1e+119]], $MachinePrecision]], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.175 \lor \neg \left(z \leq 1.1 \cdot 10^{+119}\right):\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -0.17499999999999999 or 1.1000000000000001e119 < z Initial program 98.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.0%
div-sub87.0%
*-commutative87.0%
*-lft-identity87.0%
associate-*l/86.8%
associate-*r*86.8%
lft-mult-inverse87.0%
metadata-eval87.0%
Simplified87.0%
if -0.17499999999999999 < z < 1.1000000000000001e119Initial 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 0 85.7%
Final simplification86.2%
(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 99.2%
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 -0.0155) -2.0 (if (<= z 3.4e+133) (* 4.0 (/ x z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.0155) {
tmp = -2.0;
} else if (z <= 3.4e+133) {
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 <= (-0.0155d0)) then
tmp = -2.0d0
else if (z <= 3.4d+133) 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 <= -0.0155) {
tmp = -2.0;
} else if (z <= 3.4e+133) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.0155: tmp = -2.0 elif z <= 3.4e+133: tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.0155) tmp = -2.0; elseif (z <= 3.4e+133) 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 <= -0.0155) tmp = -2.0; elseif (z <= 3.4e+133) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.0155], -2.0, If[LessEqual[z, 3.4e+133], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0155:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+133}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -0.0155 or 3.39999999999999987e133 < z Initial program 98.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 66.9%
if -0.0155 < z < 3.39999999999999987e133Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 44.5%
Final simplification53.0%
(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.2%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 34.4%
Final simplification34.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 2023175
(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))