
(FPCore (x y z) :precision binary64 (+ (* (- 1.0 x) y) (* x z)))
double code(double x, double y, double z) {
return ((1.0 - x) * y) + (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 = ((1.0d0 - x) * y) + (x * z)
end function
public static double code(double x, double y, double z) {
return ((1.0 - x) * y) + (x * z);
}
def code(x, y, z): return ((1.0 - x) * y) + (x * z)
function code(x, y, z) return Float64(Float64(Float64(1.0 - x) * y) + Float64(x * z)) end
function tmp = code(x, y, z) tmp = ((1.0 - x) * y) + (x * z); end
code[x_, y_, z_] := N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) \cdot y + x \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* (- 1.0 x) y) (* x z)))
double code(double x, double y, double z) {
return ((1.0 - x) * y) + (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 = ((1.0d0 - x) * y) + (x * z)
end function
public static double code(double x, double y, double z) {
return ((1.0 - x) * y) + (x * z);
}
def code(x, y, z): return ((1.0 - x) * y) + (x * z)
function code(x, y, z) return Float64(Float64(Float64(1.0 - x) * y) + Float64(x * z)) end
function tmp = code(x, y, z) tmp = ((1.0 - x) * y) + (x * z); end
code[x_, y_, z_] := N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) \cdot y + x \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (fma x (- z y) y))
double code(double x, double y, double z) {
return fma(x, (z - y), y);
}
function code(x, y, z) return fma(x, Float64(z - y), y) end
code[x_, y_, z_] := N[(x * N[(z - y), $MachinePrecision] + y), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, z - y, y\right)
\end{array}
Initial program 98.4%
+-commutative98.4%
*-commutative98.4%
distribute-lft-out--98.4%
*-rgt-identity98.4%
cancel-sign-sub-inv98.4%
+-commutative98.4%
associate-+r+98.4%
+-commutative98.4%
*-commutative98.4%
distribute-rgt-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 (- y))))
(if (<= x -1.35e+218)
(* x z)
(if (<= x -1e+180)
t_0
(if (<= x -4.2e+136)
(* x z)
(if (<= x -3.2e+44)
t_0
(if (or (<= x -3.2e-37)
(not
(or (<= x -9.5e-71)
(and (not (<= x -8.5e-96))
(or (<= x -7.5e-120)
(and (not (<= x -1.55e-178))
(<= x 4.1e-7)))))))
(* x z)
y)))))))
double code(double x, double y, double z) {
double t_0 = x * -y;
double tmp;
if (x <= -1.35e+218) {
tmp = x * z;
} else if (x <= -1e+180) {
tmp = t_0;
} else if (x <= -4.2e+136) {
tmp = x * z;
} else if (x <= -3.2e+44) {
tmp = t_0;
} else if ((x <= -3.2e-37) || !((x <= -9.5e-71) || (!(x <= -8.5e-96) && ((x <= -7.5e-120) || (!(x <= -1.55e-178) && (x <= 4.1e-7)))))) {
tmp = x * z;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = x * -y
if (x <= (-1.35d+218)) then
tmp = x * z
else if (x <= (-1d+180)) then
tmp = t_0
else if (x <= (-4.2d+136)) then
tmp = x * z
else if (x <= (-3.2d+44)) then
tmp = t_0
else if ((x <= (-3.2d-37)) .or. (.not. (x <= (-9.5d-71)) .or. (.not. (x <= (-8.5d-96))) .and. (x <= (-7.5d-120)) .or. (.not. (x <= (-1.55d-178))) .and. (x <= 4.1d-7))) then
tmp = x * z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -y;
double tmp;
if (x <= -1.35e+218) {
tmp = x * z;
} else if (x <= -1e+180) {
tmp = t_0;
} else if (x <= -4.2e+136) {
tmp = x * z;
} else if (x <= -3.2e+44) {
tmp = t_0;
} else if ((x <= -3.2e-37) || !((x <= -9.5e-71) || (!(x <= -8.5e-96) && ((x <= -7.5e-120) || (!(x <= -1.55e-178) && (x <= 4.1e-7)))))) {
tmp = x * z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): t_0 = x * -y tmp = 0 if x <= -1.35e+218: tmp = x * z elif x <= -1e+180: tmp = t_0 elif x <= -4.2e+136: tmp = x * z elif x <= -3.2e+44: tmp = t_0 elif (x <= -3.2e-37) or not ((x <= -9.5e-71) or (not (x <= -8.5e-96) and ((x <= -7.5e-120) or (not (x <= -1.55e-178) and (x <= 4.1e-7))))): tmp = x * z else: tmp = y return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-y)) tmp = 0.0 if (x <= -1.35e+218) tmp = Float64(x * z); elseif (x <= -1e+180) tmp = t_0; elseif (x <= -4.2e+136) tmp = Float64(x * z); elseif (x <= -3.2e+44) tmp = t_0; elseif ((x <= -3.2e-37) || !((x <= -9.5e-71) || (!(x <= -8.5e-96) && ((x <= -7.5e-120) || (!(x <= -1.55e-178) && (x <= 4.1e-7)))))) tmp = Float64(x * z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -y; tmp = 0.0; if (x <= -1.35e+218) tmp = x * z; elseif (x <= -1e+180) tmp = t_0; elseif (x <= -4.2e+136) tmp = x * z; elseif (x <= -3.2e+44) tmp = t_0; elseif ((x <= -3.2e-37) || ~(((x <= -9.5e-71) || (~((x <= -8.5e-96)) && ((x <= -7.5e-120) || (~((x <= -1.55e-178)) && (x <= 4.1e-7))))))) tmp = x * z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-y)), $MachinePrecision]}, If[LessEqual[x, -1.35e+218], N[(x * z), $MachinePrecision], If[LessEqual[x, -1e+180], t$95$0, If[LessEqual[x, -4.2e+136], N[(x * z), $MachinePrecision], If[LessEqual[x, -3.2e+44], t$95$0, If[Or[LessEqual[x, -3.2e-37], N[Not[Or[LessEqual[x, -9.5e-71], And[N[Not[LessEqual[x, -8.5e-96]], $MachinePrecision], Or[LessEqual[x, -7.5e-120], And[N[Not[LessEqual[x, -1.55e-178]], $MachinePrecision], LessEqual[x, 4.1e-7]]]]]], $MachinePrecision]], N[(x * z), $MachinePrecision], y]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-y\right)\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{+218}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{+180}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{+136}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-37} \lor \neg \left(x \leq -9.5 \cdot 10^{-71} \lor \neg \left(x \leq -8.5 \cdot 10^{-96}\right) \land \left(x \leq -7.5 \cdot 10^{-120} \lor \neg \left(x \leq -1.55 \cdot 10^{-178}\right) \land x \leq 4.1 \cdot 10^{-7}\right)\right):\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -1.35000000000000006e218 or -1e180 < x < -4.1999999999999998e136 or -3.20000000000000004e44 < x < -3.1999999999999999e-37 or -9.4999999999999994e-71 < x < -8.49999999999999983e-96 or -7.5000000000000004e-120 < x < -1.55e-178 or 4.0999999999999999e-7 < x Initial program 97.5%
Taylor expanded in y around 0 64.5%
if -1.35000000000000006e218 < x < -1e180 or -4.1999999999999998e136 < x < -3.20000000000000004e44Initial program 97.4%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 68.4%
associate-*r*68.4%
neg-mul-168.4%
*-commutative68.4%
Simplified68.4%
if -3.1999999999999999e-37 < x < -9.4999999999999994e-71 or -8.49999999999999983e-96 < x < -7.5000000000000004e-120 or -1.55e-178 < x < 4.0999999999999999e-7Initial program 100.0%
Taylor expanded in x around 0 82.1%
Final simplification71.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z y))))
(if (<= x -6.6e-38)
t_0
(if (<= x -4.6e-71)
y
(if (<= x -7.2e-97)
(* x z)
(if (<= x -7.5e-120)
y
(if (or (<= x -1.55e-178) (not (<= x 6.6e-7)))
t_0
(* y (- 1.0 x)))))))))
double code(double x, double y, double z) {
double t_0 = x * (z - y);
double tmp;
if (x <= -6.6e-38) {
tmp = t_0;
} else if (x <= -4.6e-71) {
tmp = y;
} else if (x <= -7.2e-97) {
tmp = x * z;
} else if (x <= -7.5e-120) {
tmp = y;
} else if ((x <= -1.55e-178) || !(x <= 6.6e-7)) {
tmp = t_0;
} else {
tmp = y * (1.0 - x);
}
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 - y)
if (x <= (-6.6d-38)) then
tmp = t_0
else if (x <= (-4.6d-71)) then
tmp = y
else if (x <= (-7.2d-97)) then
tmp = x * z
else if (x <= (-7.5d-120)) then
tmp = y
else if ((x <= (-1.55d-178)) .or. (.not. (x <= 6.6d-7))) then
tmp = t_0
else
tmp = y * (1.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (z - y);
double tmp;
if (x <= -6.6e-38) {
tmp = t_0;
} else if (x <= -4.6e-71) {
tmp = y;
} else if (x <= -7.2e-97) {
tmp = x * z;
} else if (x <= -7.5e-120) {
tmp = y;
} else if ((x <= -1.55e-178) || !(x <= 6.6e-7)) {
tmp = t_0;
} else {
tmp = y * (1.0 - x);
}
return tmp;
}
def code(x, y, z): t_0 = x * (z - y) tmp = 0 if x <= -6.6e-38: tmp = t_0 elif x <= -4.6e-71: tmp = y elif x <= -7.2e-97: tmp = x * z elif x <= -7.5e-120: tmp = y elif (x <= -1.55e-178) or not (x <= 6.6e-7): tmp = t_0 else: tmp = y * (1.0 - x) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z - y)) tmp = 0.0 if (x <= -6.6e-38) tmp = t_0; elseif (x <= -4.6e-71) tmp = y; elseif (x <= -7.2e-97) tmp = Float64(x * z); elseif (x <= -7.5e-120) tmp = y; elseif ((x <= -1.55e-178) || !(x <= 6.6e-7)) tmp = t_0; else tmp = Float64(y * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z - y); tmp = 0.0; if (x <= -6.6e-38) tmp = t_0; elseif (x <= -4.6e-71) tmp = y; elseif (x <= -7.2e-97) tmp = x * z; elseif (x <= -7.5e-120) tmp = y; elseif ((x <= -1.55e-178) || ~((x <= 6.6e-7))) tmp = t_0; else tmp = y * (1.0 - x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.6e-38], t$95$0, If[LessEqual[x, -4.6e-71], y, If[LessEqual[x, -7.2e-97], N[(x * z), $MachinePrecision], If[LessEqual[x, -7.5e-120], y, If[Or[LessEqual[x, -1.55e-178], N[Not[LessEqual[x, 6.6e-7]], $MachinePrecision]], t$95$0, N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z - y\right)\\
\mathbf{if}\;x \leq -6.6 \cdot 10^{-38}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{-71}:\\
\;\;\;\;y\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{-97}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;x \leq -7.5 \cdot 10^{-120}:\\
\;\;\;\;y\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-178} \lor \neg \left(x \leq 6.6 \cdot 10^{-7}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -6.6000000000000005e-38 or -7.5000000000000004e-120 < x < -1.55e-178 or 6.6000000000000003e-7 < x Initial program 97.4%
Taylor expanded in x around inf 93.7%
mul-1-neg93.7%
sub-neg93.7%
Simplified93.7%
if -6.6000000000000005e-38 < x < -4.5999999999999997e-71 or -7.19999999999999995e-97 < x < -7.5000000000000004e-120Initial program 100.0%
Taylor expanded in x around 0 100.0%
if -4.5999999999999997e-71 < x < -7.19999999999999995e-97Initial program 100.0%
Taylor expanded in y around 0 100.0%
if -1.55e-178 < x < 6.6000000000000003e-7Initial program 100.0%
Taylor expanded in y around inf 80.9%
Final simplification90.2%
(FPCore (x y z)
:precision binary64
(if (or (<= x -3.4e-38)
(and (not (<= x -3.5e-71))
(or (<= x -1.55e-178) (not (<= x 4.1e-7)))))
(* x (- z y))
y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.4e-38) || (!(x <= -3.5e-71) && ((x <= -1.55e-178) || !(x <= 4.1e-7)))) {
tmp = x * (z - y);
} else {
tmp = 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 <= (-3.4d-38)) .or. (.not. (x <= (-3.5d-71))) .and. (x <= (-1.55d-178)) .or. (.not. (x <= 4.1d-7))) then
tmp = x * (z - y)
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.4e-38) || (!(x <= -3.5e-71) && ((x <= -1.55e-178) || !(x <= 4.1e-7)))) {
tmp = x * (z - y);
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.4e-38) or (not (x <= -3.5e-71) and ((x <= -1.55e-178) or not (x <= 4.1e-7))): tmp = x * (z - y) else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.4e-38) || (!(x <= -3.5e-71) && ((x <= -1.55e-178) || !(x <= 4.1e-7)))) tmp = Float64(x * Float64(z - y)); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.4e-38) || (~((x <= -3.5e-71)) && ((x <= -1.55e-178) || ~((x <= 4.1e-7))))) tmp = x * (z - y); else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.4e-38], And[N[Not[LessEqual[x, -3.5e-71]], $MachinePrecision], Or[LessEqual[x, -1.55e-178], N[Not[LessEqual[x, 4.1e-7]], $MachinePrecision]]]], N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{-38} \lor \neg \left(x \leq -3.5 \cdot 10^{-71}\right) \land \left(x \leq -1.55 \cdot 10^{-178} \lor \neg \left(x \leq 4.1 \cdot 10^{-7}\right)\right):\\
\;\;\;\;x \cdot \left(z - y\right)\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -3.4000000000000002e-38 or -3.4999999999999999e-71 < x < -1.55e-178 or 4.0999999999999999e-7 < x Initial program 97.6%
Taylor expanded in x around inf 91.3%
mul-1-neg91.3%
sub-neg91.3%
Simplified91.3%
if -3.4000000000000002e-38 < x < -3.4999999999999999e-71 or -1.55e-178 < x < 4.0999999999999999e-7Initial program 100.0%
Taylor expanded in x around 0 81.1%
Final simplification87.8%
(FPCore (x y z)
:precision binary64
(if (or (<= x -7e-40)
(and (not (<= x -5.9e-71))
(or (<= x -1.55e-178) (not (<= x 4.1e-7)))))
(* x z)
y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7e-40) || (!(x <= -5.9e-71) && ((x <= -1.55e-178) || !(x <= 4.1e-7)))) {
tmp = x * z;
} else {
tmp = 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 <= (-7d-40)) .or. (.not. (x <= (-5.9d-71))) .and. (x <= (-1.55d-178)) .or. (.not. (x <= 4.1d-7))) then
tmp = x * z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -7e-40) || (!(x <= -5.9e-71) && ((x <= -1.55e-178) || !(x <= 4.1e-7)))) {
tmp = x * z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7e-40) or (not (x <= -5.9e-71) and ((x <= -1.55e-178) or not (x <= 4.1e-7))): tmp = x * z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7e-40) || (!(x <= -5.9e-71) && ((x <= -1.55e-178) || !(x <= 4.1e-7)))) tmp = Float64(x * z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -7e-40) || (~((x <= -5.9e-71)) && ((x <= -1.55e-178) || ~((x <= 4.1e-7))))) tmp = x * z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7e-40], And[N[Not[LessEqual[x, -5.9e-71]], $MachinePrecision], Or[LessEqual[x, -1.55e-178], N[Not[LessEqual[x, 4.1e-7]], $MachinePrecision]]]], N[(x * z), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-40} \lor \neg \left(x \leq -5.9 \cdot 10^{-71}\right) \land \left(x \leq -1.55 \cdot 10^{-178} \lor \neg \left(x \leq 4.1 \cdot 10^{-7}\right)\right):\\
\;\;\;\;x \cdot z\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -7.0000000000000003e-40 or -5.90000000000000002e-71 < x < -1.55e-178 or 4.0999999999999999e-7 < x Initial program 97.6%
Taylor expanded in y around 0 55.3%
if -7.0000000000000003e-40 < x < -5.90000000000000002e-71 or -1.55e-178 < x < 4.0999999999999999e-7Initial program 100.0%
Taylor expanded in x around 0 81.1%
Final simplification64.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -33000000000.0) (not (<= x 1.0))) (* x (- z y)) (+ y (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -33000000000.0) || !(x <= 1.0)) {
tmp = x * (z - y);
} else {
tmp = y + (x * 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.0d0))) then
tmp = x * (z - y)
else
tmp = y + (x * 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.0)) {
tmp = x * (z - y);
} else {
tmp = y + (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -33000000000.0) or not (x <= 1.0): tmp = x * (z - y) else: tmp = y + (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -33000000000.0) || !(x <= 1.0)) tmp = Float64(x * Float64(z - y)); else tmp = Float64(y + Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -33000000000.0) || ~((x <= 1.0))) tmp = x * (z - y); else tmp = y + (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -33000000000.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision], N[(y + N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -33000000000 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;x \cdot \left(z - y\right)\\
\mathbf{else}:\\
\;\;\;\;y + x \cdot z\\
\end{array}
\end{array}
if x < -3.3e10 or 1 < x Initial program 96.9%
Taylor expanded in x around inf 98.6%
mul-1-neg98.6%
sub-neg98.6%
Simplified98.6%
if -3.3e10 < x < 1Initial program 100.0%
*-commutative100.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 0 97.8%
neg-mul-197.8%
distribute-rgt-neg-in97.8%
Simplified97.8%
sub-neg97.8%
+-commutative97.8%
distribute-rgt-neg-out97.8%
remove-double-neg97.8%
Applied egg-rr97.8%
Final simplification98.2%
(FPCore (x y z) :precision binary64 (+ y (* x (- z y))))
double code(double x, double y, double z) {
return y + (x * (z - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y + (x * (z - y))
end function
public static double code(double x, double y, double z) {
return y + (x * (z - y));
}
def code(x, y, z): return y + (x * (z - y))
function code(x, y, z) return Float64(y + Float64(x * Float64(z - y))) end
function tmp = code(x, y, z) tmp = y + (x * (z - y)); end
code[x_, y_, z_] := N[(y + N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + x \cdot \left(z - y\right)
\end{array}
Initial program 98.4%
*-commutative98.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 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 98.4%
Taylor expanded in x around 0 34.3%
Final simplification34.3%
(FPCore (x y z) :precision binary64 (- y (* x (- y z))))
double code(double x, double y, double z) {
return y - (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 = y - (x * (y - z))
end function
public static double code(double x, double y, double z) {
return y - (x * (y - z));
}
def code(x, y, z): return y - (x * (y - z))
function code(x, y, z) return Float64(y - Float64(x * Float64(y - z))) end
function tmp = code(x, y, z) tmp = y - (x * (y - z)); end
code[x_, y_, z_] := N[(y - N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y - x \cdot \left(y - z\right)
\end{array}
herbie shell --seed 2024115
(FPCore (x y z)
:name "Diagrams.Color.HSV:lerp from diagrams-contrib-1.3.0.5"
:precision binary64
:alt
(- y (* x (- y z)))
(+ (* (- 1.0 x) y) (* x z)))