
(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
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* -4.0 (/ y z))))
(if (<= x -720.0)
t_0
(if (<= x -1.15e-257)
t_1
(if (<= x 2.9e-150) -2.0 (if (<= x 1.35e+107) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -720.0) {
tmp = t_0;
} else if (x <= -1.15e-257) {
tmp = t_1;
} else if (x <= 2.9e-150) {
tmp = -2.0;
} else if (x <= 1.35e+107) {
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 * (x / z)
t_1 = (-4.0d0) * (y / z)
if (x <= (-720.0d0)) then
tmp = t_0
else if (x <= (-1.15d-257)) then
tmp = t_1
else if (x <= 2.9d-150) then
tmp = -2.0d0
else if (x <= 1.35d+107) 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 * (x / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -720.0) {
tmp = t_0;
} else if (x <= -1.15e-257) {
tmp = t_1;
} else if (x <= 2.9e-150) {
tmp = -2.0;
} else if (x <= 1.35e+107) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = -4.0 * (y / z) tmp = 0 if x <= -720.0: tmp = t_0 elif x <= -1.15e-257: tmp = t_1 elif x <= 2.9e-150: tmp = -2.0 elif x <= 1.35e+107: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (x <= -720.0) tmp = t_0; elseif (x <= -1.15e-257) tmp = t_1; elseif (x <= 2.9e-150) tmp = -2.0; elseif (x <= 1.35e+107) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); t_1 = -4.0 * (y / z); tmp = 0.0; if (x <= -720.0) tmp = t_0; elseif (x <= -1.15e-257) tmp = t_1; elseif (x <= 2.9e-150) tmp = -2.0; elseif (x <= 1.35e+107) tmp = t_1; 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]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -720.0], t$95$0, If[LessEqual[x, -1.15e-257], t$95$1, If[LessEqual[x, 2.9e-150], -2.0, If[LessEqual[x, 1.35e+107], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -720:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{-257}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-150}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+107}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -720 or 1.3500000000000001e107 < x Initial program 100.0%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 74.4%
if -720 < x < -1.15e-257 or 2.8999999999999998e-150 < x < 1.3500000000000001e107Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 59.0%
if -1.15e-257 < x < 2.8999999999999998e-150Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 63.9%
Final simplification65.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.6e-43) (not (<= x 1.35e-12))) (* (- x y) (/ 4.0 z)) (- (* -4.0 (/ y z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.6e-43) || !(x <= 1.35e-12)) {
tmp = (x - y) * (4.0 / 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 <= (-5.6d-43)) .or. (.not. (x <= 1.35d-12))) then
tmp = (x - y) * (4.0d0 / 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 <= -5.6e-43) || !(x <= 1.35e-12)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.6e-43) or not (x <= 1.35e-12): tmp = (x - y) * (4.0 / z) else: tmp = (-4.0 * (y / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.6e-43) || !(x <= 1.35e-12)) tmp = Float64(Float64(x - y) * Float64(4.0 / 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 <= -5.6e-43) || ~((x <= 1.35e-12))) tmp = (x - y) * (4.0 / z); else tmp = (-4.0 * (y / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.6e-43], N[Not[LessEqual[x, 1.35e-12]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{-43} \lor \neg \left(x \leq 1.35 \cdot 10^{-12}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if x < -5.5999999999999996e-43 or 1.3499999999999999e-12 < x Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 87.4%
if -5.5999999999999996e-43 < x < 1.3499999999999999e-12Initial 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-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 93.1%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.2e+116) (not (<= z 7.5e-34))) (- (* 4.0 (/ x z)) 2.0) (* (- x y) (/ 4.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.2e+116) || !(z <= 7.5e-34)) {
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 ((z <= (-1.2d+116)) .or. (.not. (z <= 7.5d-34))) 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 ((z <= -1.2e+116) || !(z <= 7.5e-34)) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.2e+116) or not (z <= 7.5e-34): 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 ((z <= -1.2e+116) || !(z <= 7.5e-34)) 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 ((z <= -1.2e+116) || ~((z <= 7.5e-34))) tmp = (4.0 * (x / z)) - 2.0; else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.2e+116], N[Not[LessEqual[z, 7.5e-34]], $MachinePrecision]], 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}\;z \leq -1.2 \cdot 10^{+116} \lor \neg \left(z \leq 7.5 \cdot 10^{-34}\right):\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if z < -1.2e116 or 7.5000000000000004e-34 < z Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*100.0%
associate-/r/99.9%
fma-neg99.9%
metadata-eval99.9%
/-rgt-identity99.9%
associate-/r/99.9%
distribute-lft-neg-in99.9%
distribute-frac-neg99.9%
*-commutative99.9%
distribute-lft-neg-in99.9%
associate-/l*99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 83.5%
if -1.2e116 < z < 7.5000000000000004e-34Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 91.6%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.25e+172) -2.0 (if (<= z 7.8e+158) (* (- x y) (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.25e+172) {
tmp = -2.0;
} else if (z <= 7.8e+158) {
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 (z <= (-1.25d+172)) then
tmp = -2.0d0
else if (z <= 7.8d+158) 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 (z <= -1.25e+172) {
tmp = -2.0;
} else if (z <= 7.8e+158) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.25e+172: tmp = -2.0 elif z <= 7.8e+158: tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.25e+172) tmp = -2.0; elseif (z <= 7.8e+158) 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 (z <= -1.25e+172) tmp = -2.0; elseif (z <= 7.8e+158) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.25e+172], -2.0, If[LessEqual[z, 7.8e+158], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+172}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{+158}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.25e172 or 7.8e158 < z Initial program 100.0%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 79.5%
if -1.25e172 < z < 7.8e158Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 84.9%
Final simplification83.8%
(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%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.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.1e-44) (not (<= y 215000.0))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.1e-44) || !(y <= 215000.0)) {
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.1d-44)) .or. (.not. (y <= 215000.0d0))) 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.1e-44) || !(y <= 215000.0)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.1e-44) or not (y <= 215000.0): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.1e-44) || !(y <= 215000.0)) 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.1e-44) || ~((y <= 215000.0))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.1e-44], N[Not[LessEqual[y, 215000.0]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.1 \cdot 10^{-44} \lor \neg \left(y \leq 215000\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -5.1000000000000005e-44 or 215000 < y Initial program 100.0%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 64.5%
if -5.1000000000000005e-44 < y < 215000Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 43.8%
Final simplification55.3%
(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%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 29.4%
Final simplification29.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 2024011
(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))