
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + ((1.0d0 - x) * z)
end function
public static double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
def code(x, y, z): return (x * y) + ((1.0 - x) * z)
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(1.0 - x) * z)) end
function tmp = code(x, y, z) tmp = (x * y) + ((1.0 - x) * z); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + \left(1 - x\right) \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- 1.0 x) z)))
double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + ((1.0d0 - x) * z)
end function
public static double code(double x, double y, double z) {
return (x * y) + ((1.0 - x) * z);
}
def code(x, y, z): return (x * y) + ((1.0 - x) * z)
function code(x, y, z) return Float64(Float64(x * y) + Float64(Float64(1.0 - x) * z)) end
function tmp = code(x, y, z) tmp = (x * y) + ((1.0 - x) * z); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + \left(1 - x\right) \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (fma x (- y z) z))
double code(double x, double y, double z) {
return fma(x, (y - z), z);
}
function code(x, y, z) return fma(x, Float64(y - z), z) end
code[x_, y_, z_] := N[(x * N[(y - z), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y - z, z\right)
\end{array}
Initial program 98.4%
sub-neg98.4%
+-commutative98.4%
distribute-lft1-in98.4%
associate-+r+98.4%
+-commutative98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
distribute-lft-out99.9%
fma-define100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x z))))
(if (<= x -1.32e+218)
t_0
(if (<= x -1e+178)
(* x y)
(if (<= x -7.8e+135)
t_0
(if (<= x -5.7e+45)
(* x y)
(if (<= x -1.0)
t_0
(if (<= x -8.6e-41)
z
(if (<= x -2e-64)
(* x y)
(if (<= x 1.6e-97)
z
(if (or (<= x 9e+43) (not (<= x 2.8e+240)))
(* x y)
t_0)))))))))))
double code(double x, double y, double z) {
double t_0 = -(x * z);
double tmp;
if (x <= -1.32e+218) {
tmp = t_0;
} else if (x <= -1e+178) {
tmp = x * y;
} else if (x <= -7.8e+135) {
tmp = t_0;
} else if (x <= -5.7e+45) {
tmp = x * y;
} else if (x <= -1.0) {
tmp = t_0;
} else if (x <= -8.6e-41) {
tmp = z;
} else if (x <= -2e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = z;
} else if ((x <= 9e+43) || !(x <= 2.8e+240)) {
tmp = x * y;
} 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 = -(x * z)
if (x <= (-1.32d+218)) then
tmp = t_0
else if (x <= (-1d+178)) then
tmp = x * y
else if (x <= (-7.8d+135)) then
tmp = t_0
else if (x <= (-5.7d+45)) then
tmp = x * y
else if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= (-8.6d-41)) then
tmp = z
else if (x <= (-2d-64)) then
tmp = x * y
else if (x <= 1.6d-97) then
tmp = z
else if ((x <= 9d+43) .or. (.not. (x <= 2.8d+240))) then
tmp = x * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -(x * z);
double tmp;
if (x <= -1.32e+218) {
tmp = t_0;
} else if (x <= -1e+178) {
tmp = x * y;
} else if (x <= -7.8e+135) {
tmp = t_0;
} else if (x <= -5.7e+45) {
tmp = x * y;
} else if (x <= -1.0) {
tmp = t_0;
} else if (x <= -8.6e-41) {
tmp = z;
} else if (x <= -2e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = z;
} else if ((x <= 9e+43) || !(x <= 2.8e+240)) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -(x * z) tmp = 0 if x <= -1.32e+218: tmp = t_0 elif x <= -1e+178: tmp = x * y elif x <= -7.8e+135: tmp = t_0 elif x <= -5.7e+45: tmp = x * y elif x <= -1.0: tmp = t_0 elif x <= -8.6e-41: tmp = z elif x <= -2e-64: tmp = x * y elif x <= 1.6e-97: tmp = z elif (x <= 9e+43) or not (x <= 2.8e+240): tmp = x * y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-Float64(x * z)) tmp = 0.0 if (x <= -1.32e+218) tmp = t_0; elseif (x <= -1e+178) tmp = Float64(x * y); elseif (x <= -7.8e+135) tmp = t_0; elseif (x <= -5.7e+45) tmp = Float64(x * y); elseif (x <= -1.0) tmp = t_0; elseif (x <= -8.6e-41) tmp = z; elseif (x <= -2e-64) tmp = Float64(x * y); elseif (x <= 1.6e-97) tmp = z; elseif ((x <= 9e+43) || !(x <= 2.8e+240)) tmp = Float64(x * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(x * z); tmp = 0.0; if (x <= -1.32e+218) tmp = t_0; elseif (x <= -1e+178) tmp = x * y; elseif (x <= -7.8e+135) tmp = t_0; elseif (x <= -5.7e+45) tmp = x * y; elseif (x <= -1.0) tmp = t_0; elseif (x <= -8.6e-41) tmp = z; elseif (x <= -2e-64) tmp = x * y; elseif (x <= 1.6e-97) tmp = z; elseif ((x <= 9e+43) || ~((x <= 2.8e+240))) tmp = x * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(x * z), $MachinePrecision])}, If[LessEqual[x, -1.32e+218], t$95$0, If[LessEqual[x, -1e+178], N[(x * y), $MachinePrecision], If[LessEqual[x, -7.8e+135], t$95$0, If[LessEqual[x, -5.7e+45], N[(x * y), $MachinePrecision], If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -8.6e-41], z, If[LessEqual[x, -2e-64], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.6e-97], z, If[Or[LessEqual[x, 9e+43], N[Not[LessEqual[x, 2.8e+240]], $MachinePrecision]], N[(x * y), $MachinePrecision], t$95$0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -x \cdot z\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+218}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1 \cdot 10^{+178}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -7.8 \cdot 10^{+135}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.7 \cdot 10^{+45}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -8.6 \cdot 10^{-41}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-64}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-97}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+43} \lor \neg \left(x \leq 2.8 \cdot 10^{+240}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.32e218 or -1.0000000000000001e178 < x < -7.80000000000000064e135 or -5.70000000000000027e45 < x < -1 or 9e43 < x < 2.8000000000000001e240Initial program 97.0%
Taylor expanded in x around inf 97.9%
mul-1-neg97.9%
sub-neg97.9%
Simplified97.9%
Taylor expanded in y around 0 68.7%
associate-*r*68.7%
mul-1-neg68.7%
Simplified68.7%
if -1.32e218 < x < -1.0000000000000001e178 or -7.80000000000000064e135 < x < -5.70000000000000027e45 or -8.5999999999999997e-41 < x < -1.99999999999999993e-64 or 1.5999999999999999e-97 < x < 9e43 or 2.8000000000000001e240 < x Initial program 97.8%
Taylor expanded in y around inf 68.2%
if -1 < x < -8.5999999999999997e-41 or -1.99999999999999993e-64 < x < 1.5999999999999999e-97Initial program 100.0%
Taylor expanded in x around 0 82.0%
Final simplification73.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- y z))))
(if (<= x -0.0075)
t_0
(if (<= x -6.5e-44)
z
(if (<= x -1.8e-64) (* x y) (if (<= x 1.6e-97) z t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (y - z);
double tmp;
if (x <= -0.0075) {
tmp = t_0;
} else if (x <= -6.5e-44) {
tmp = z;
} else if (x <= -1.8e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = 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 = x * (y - z)
if (x <= (-0.0075d0)) then
tmp = t_0
else if (x <= (-6.5d-44)) then
tmp = z
else if (x <= (-1.8d-64)) then
tmp = x * y
else if (x <= 1.6d-97) then
tmp = z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y - z);
double tmp;
if (x <= -0.0075) {
tmp = t_0;
} else if (x <= -6.5e-44) {
tmp = z;
} else if (x <= -1.8e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y - z) tmp = 0 if x <= -0.0075: tmp = t_0 elif x <= -6.5e-44: tmp = z elif x <= -1.8e-64: tmp = x * y elif x <= 1.6e-97: tmp = z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y - z)) tmp = 0.0 if (x <= -0.0075) tmp = t_0; elseif (x <= -6.5e-44) tmp = z; elseif (x <= -1.8e-64) tmp = Float64(x * y); elseif (x <= 1.6e-97) tmp = z; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y - z); tmp = 0.0; if (x <= -0.0075) tmp = t_0; elseif (x <= -6.5e-44) tmp = z; elseif (x <= -1.8e-64) tmp = x * y; elseif (x <= 1.6e-97) tmp = z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.0075], t$95$0, If[LessEqual[x, -6.5e-44], z, If[LessEqual[x, -1.8e-64], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.6e-97], z, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y - z\right)\\
\mathbf{if}\;x \leq -0.0075:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-44}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-64}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-97}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -0.0074999999999999997 or 1.5999999999999999e-97 < x Initial program 97.4%
Taylor expanded in x around inf 93.9%
mul-1-neg93.9%
sub-neg93.9%
Simplified93.9%
if -0.0074999999999999997 < x < -6.5e-44 or -1.7999999999999999e-64 < x < 1.5999999999999999e-97Initial program 100.0%
Taylor expanded in x around 0 82.0%
if -6.5e-44 < x < -1.7999999999999999e-64Initial program 100.0%
Taylor expanded in y around inf 100.0%
Final simplification89.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- y z))) (t_1 (* z (- 1.0 x))))
(if (<= x -33000000000.0)
t_0
(if (<= x -8.5e-44)
t_1
(if (<= x -1.3e-64) (* x y) (if (<= x 1.6e-97) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (y - z);
double t_1 = z * (1.0 - x);
double tmp;
if (x <= -33000000000.0) {
tmp = t_0;
} else if (x <= -8.5e-44) {
tmp = t_1;
} else if (x <= -1.3e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
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 = x * (y - z)
t_1 = z * (1.0d0 - x)
if (x <= (-33000000000.0d0)) then
tmp = t_0
else if (x <= (-8.5d-44)) then
tmp = t_1
else if (x <= (-1.3d-64)) then
tmp = x * y
else if (x <= 1.6d-97) 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 = x * (y - z);
double t_1 = z * (1.0 - x);
double tmp;
if (x <= -33000000000.0) {
tmp = t_0;
} else if (x <= -8.5e-44) {
tmp = t_1;
} else if (x <= -1.3e-64) {
tmp = x * y;
} else if (x <= 1.6e-97) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y - z) t_1 = z * (1.0 - x) tmp = 0 if x <= -33000000000.0: tmp = t_0 elif x <= -8.5e-44: tmp = t_1 elif x <= -1.3e-64: tmp = x * y elif x <= 1.6e-97: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y - z)) t_1 = Float64(z * Float64(1.0 - x)) tmp = 0.0 if (x <= -33000000000.0) tmp = t_0; elseif (x <= -8.5e-44) tmp = t_1; elseif (x <= -1.3e-64) tmp = Float64(x * y); elseif (x <= 1.6e-97) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y - z); t_1 = z * (1.0 - x); tmp = 0.0; if (x <= -33000000000.0) tmp = t_0; elseif (x <= -8.5e-44) tmp = t_1; elseif (x <= -1.3e-64) tmp = x * y; elseif (x <= 1.6e-97) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -33000000000.0], t$95$0, If[LessEqual[x, -8.5e-44], t$95$1, If[LessEqual[x, -1.3e-64], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.6e-97], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y - z\right)\\
t_1 := z \cdot \left(1 - x\right)\\
\mathbf{if}\;x \leq -33000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{-64}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-97}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.3e10 or 1.5999999999999999e-97 < x Initial program 97.3%
Taylor expanded in x around inf 94.7%
mul-1-neg94.7%
sub-neg94.7%
Simplified94.7%
if -3.3e10 < x < -8.5000000000000002e-44 or -1.3e-64 < x < 1.5999999999999999e-97Initial program 100.0%
Taylor expanded in y around 0 83.7%
if -8.5000000000000002e-44 < x < -1.3e-64Initial program 100.0%
Taylor expanded in y around inf 100.0%
Final simplification90.5%
(FPCore (x y z)
:precision binary64
(if (or (<= x -33000000000.0)
(and (not (<= x -1.7e-42)) (or (<= x -1.8e-64) (not (<= x 1.5e-97)))))
(* x y)
z))
double code(double x, double y, double z) {
double tmp;
if ((x <= -33000000000.0) || (!(x <= -1.7e-42) && ((x <= -1.8e-64) || !(x <= 1.5e-97)))) {
tmp = x * y;
} else {
tmp = 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 <= (-33000000000.0d0)) .or. (.not. (x <= (-1.7d-42))) .and. (x <= (-1.8d-64)) .or. (.not. (x <= 1.5d-97))) then
tmp = x * y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -33000000000.0) || (!(x <= -1.7e-42) && ((x <= -1.8e-64) || !(x <= 1.5e-97)))) {
tmp = x * y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -33000000000.0) or (not (x <= -1.7e-42) and ((x <= -1.8e-64) or not (x <= 1.5e-97))): tmp = x * y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -33000000000.0) || (!(x <= -1.7e-42) && ((x <= -1.8e-64) || !(x <= 1.5e-97)))) tmp = Float64(x * y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -33000000000.0) || (~((x <= -1.7e-42)) && ((x <= -1.8e-64) || ~((x <= 1.5e-97))))) tmp = x * y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -33000000000.0], And[N[Not[LessEqual[x, -1.7e-42]], $MachinePrecision], Or[LessEqual[x, -1.8e-64], N[Not[LessEqual[x, 1.5e-97]], $MachinePrecision]]]], N[(x * y), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -33000000000 \lor \neg \left(x \leq -1.7 \cdot 10^{-42}\right) \land \left(x \leq -1.8 \cdot 10^{-64} \lor \neg \left(x \leq 1.5 \cdot 10^{-97}\right)\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -3.3e10 or -1.70000000000000011e-42 < x < -1.7999999999999999e-64 or 1.50000000000000012e-97 < x Initial program 97.4%
Taylor expanded in y around inf 55.2%
if -3.3e10 < x < -1.70000000000000011e-42 or -1.7999999999999999e-64 < x < 1.50000000000000012e-97Initial program 100.0%
Taylor expanded in x around 0 79.9%
Final simplification64.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.46))) (* x (- y z)) (+ z (* x y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.0) || !(x <= 0.46)) {
tmp = x * (y - z);
} else {
tmp = z + (x * y);
}
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.0d0)) .or. (.not. (x <= 0.46d0))) then
tmp = x * (y - z)
else
tmp = z + (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.0) || !(x <= 0.46)) {
tmp = x * (y - z);
} else {
tmp = z + (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.0) or not (x <= 0.46): tmp = x * (y - z) else: tmp = z + (x * y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.46)) tmp = Float64(x * Float64(y - z)); else tmp = Float64(z + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.0) || ~((x <= 0.46))) tmp = x * (y - z); else tmp = z + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 0.46]], $MachinePrecision]], N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.46\right):\\
\;\;\;\;x \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot y\\
\end{array}
\end{array}
if x < -1 or 0.46000000000000002 < x Initial program 97.0%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
sub-neg97.5%
Simplified97.5%
if -1 < x < 0.46000000000000002Initial program 100.0%
+-commutative100.0%
remove-double-neg100.0%
distribute-rgt-neg-out100.0%
neg-sub0100.0%
neg-sub0100.0%
*-commutative100.0%
distribute-lft-neg-in100.0%
remove-double-neg100.0%
distribute-rgt-out--100.0%
*-lft-identity100.0%
associate-+l-100.0%
distribute-lft-out--100.0%
Simplified100.0%
Taylor expanded in y around inf 96.9%
neg-mul-196.9%
+-commutative96.9%
distribute-rgt-in96.9%
*-commutative96.9%
neg-mul-196.9%
associate-*r*96.9%
associate-/l*92.1%
associate-*r*91.8%
*-commutative91.8%
*-commutative91.8%
distribute-lft-out91.8%
Simplified91.8%
Taylor expanded in y around inf 97.6%
associate-*r*97.6%
mul-1-neg97.6%
Simplified97.6%
cancel-sign-sub97.6%
+-commutative97.6%
Applied egg-rr97.6%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (+ z (* x (- y z))))
double code(double x, double y, double z) {
return z + (x * (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 = z + (x * (y - z))
end function
public static double code(double x, double y, double z) {
return z + (x * (y - z));
}
def code(x, y, z): return z + (x * (y - z))
function code(x, y, z) return Float64(z + Float64(x * Float64(y - z))) end
function tmp = code(x, y, z) tmp = z + (x * (y - z)); end
code[x_, y_, z_] := N[(z + N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + x \cdot \left(y - z\right)
\end{array}
Initial program 98.4%
+-commutative98.4%
remove-double-neg98.4%
distribute-rgt-neg-out98.4%
neg-sub098.4%
neg-sub098.4%
*-commutative98.4%
distribute-lft-neg-in98.4%
remove-double-neg98.4%
distribute-rgt-out--98.4%
*-lft-identity98.4%
associate-+l-98.4%
distribute-lft-out--99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 98.4%
Taylor expanded in x around 0 35.3%
Final simplification35.3%
herbie shell --seed 2024115
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
:precision binary64
(+ (* x y) (* (- 1.0 x) z)))