
(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 9 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 97.6%
sub-neg97.6%
+-commutative97.6%
distribute-lft1-in97.6%
associate-+r+97.6%
+-commutative97.6%
*-commutative97.6%
neg-mul-197.6%
associate-*r*97.6%
*-commutative97.6%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
*-commutative100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- 1.0 x))))
(if (<= z -2.15e-54)
t_0
(if (<= z -5.1e-82)
(* x (+ y z))
(if (or (<= z -1.65e-142)
(and (not (<= z 4.3e-109))
(or (<= z 0.28) (not (<= z 4.5e+15)))))
t_0
(* x y))))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - x);
double tmp;
if (z <= -2.15e-54) {
tmp = t_0;
} else if (z <= -5.1e-82) {
tmp = x * (y + z);
} else if ((z <= -1.65e-142) || (!(z <= 4.3e-109) && ((z <= 0.28) || !(z <= 4.5e+15)))) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = z * (1.0d0 - x)
if (z <= (-2.15d-54)) then
tmp = t_0
else if (z <= (-5.1d-82)) then
tmp = x * (y + z)
else if ((z <= (-1.65d-142)) .or. (.not. (z <= 4.3d-109)) .and. (z <= 0.28d0) .or. (.not. (z <= 4.5d+15))) then
tmp = t_0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (1.0 - x);
double tmp;
if (z <= -2.15e-54) {
tmp = t_0;
} else if (z <= -5.1e-82) {
tmp = x * (y + z);
} else if ((z <= -1.65e-142) || (!(z <= 4.3e-109) && ((z <= 0.28) || !(z <= 4.5e+15)))) {
tmp = t_0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - x) tmp = 0 if z <= -2.15e-54: tmp = t_0 elif z <= -5.1e-82: tmp = x * (y + z) elif (z <= -1.65e-142) or (not (z <= 4.3e-109) and ((z <= 0.28) or not (z <= 4.5e+15))): tmp = t_0 else: tmp = x * y return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - x)) tmp = 0.0 if (z <= -2.15e-54) tmp = t_0; elseif (z <= -5.1e-82) tmp = Float64(x * Float64(y + z)); elseif ((z <= -1.65e-142) || (!(z <= 4.3e-109) && ((z <= 0.28) || !(z <= 4.5e+15)))) tmp = t_0; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - x); tmp = 0.0; if (z <= -2.15e-54) tmp = t_0; elseif (z <= -5.1e-82) tmp = x * (y + z); elseif ((z <= -1.65e-142) || (~((z <= 4.3e-109)) && ((z <= 0.28) || ~((z <= 4.5e+15))))) tmp = t_0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.15e-54], t$95$0, If[LessEqual[z, -5.1e-82], N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -1.65e-142], And[N[Not[LessEqual[z, 4.3e-109]], $MachinePrecision], Or[LessEqual[z, 0.28], N[Not[LessEqual[z, 4.5e+15]], $MachinePrecision]]]], t$95$0, N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - x\right)\\
\mathbf{if}\;z \leq -2.15 \cdot 10^{-54}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -5.1 \cdot 10^{-82}:\\
\;\;\;\;x \cdot \left(y + z\right)\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{-142} \lor \neg \left(z \leq 4.3 \cdot 10^{-109}\right) \land \left(z \leq 0.28 \lor \neg \left(z \leq 4.5 \cdot 10^{+15}\right)\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if z < -2.15e-54 or -5.09999999999999992e-82 < z < -1.6499999999999998e-142 or 4.2999999999999997e-109 < z < 0.28000000000000003 or 4.5e15 < z Initial program 96.3%
Taylor expanded in y around 0 90.6%
if -2.15e-54 < z < -5.09999999999999992e-82Initial program 99.9%
Taylor expanded in x around inf 69.3%
neg-mul-169.3%
+-commutative69.3%
unsub-neg69.3%
Simplified69.3%
sub-neg69.3%
mul-1-neg69.3%
+-commutative69.3%
add-log-exp26.2%
*-un-lft-identity26.2%
log-prod26.2%
metadata-eval26.2%
add-log-exp69.3%
*-commutative69.3%
add-sqr-sqrt69.3%
sqrt-unprod69.3%
mul-1-neg69.3%
mul-1-neg69.3%
sqr-neg69.3%
sqrt-unprod0.0%
add-sqr-sqrt69.6%
Applied egg-rr69.6%
+-lft-identity69.6%
Simplified69.6%
if -1.6499999999999998e-142 < z < 4.2999999999999997e-109 or 0.28000000000000003 < z < 4.5e15Initial program 100.0%
Taylor expanded in y around inf 81.3%
Final simplification86.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))))
(if (<= x -1.2e+24)
t_0
(if (<= x -3.2e-15)
(* x y)
(if (<= x 1.6e-29) z (if (<= x 2.25e+29) (* x (+ y z)) t_0))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (x <= -1.2e+24) {
tmp = t_0;
} else if (x <= -3.2e-15) {
tmp = x * y;
} else if (x <= 1.6e-29) {
tmp = z;
} else if (x <= 2.25e+29) {
tmp = x * (y + 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 * -z
if (x <= (-1.2d+24)) then
tmp = t_0
else if (x <= (-3.2d-15)) then
tmp = x * y
else if (x <= 1.6d-29) then
tmp = z
else if (x <= 2.25d+29) then
tmp = x * (y + 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 * -z;
double tmp;
if (x <= -1.2e+24) {
tmp = t_0;
} else if (x <= -3.2e-15) {
tmp = x * y;
} else if (x <= 1.6e-29) {
tmp = z;
} else if (x <= 2.25e+29) {
tmp = x * (y + z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if x <= -1.2e+24: tmp = t_0 elif x <= -3.2e-15: tmp = x * y elif x <= 1.6e-29: tmp = z elif x <= 2.25e+29: tmp = x * (y + z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (x <= -1.2e+24) tmp = t_0; elseif (x <= -3.2e-15) tmp = Float64(x * y); elseif (x <= 1.6e-29) tmp = z; elseif (x <= 2.25e+29) tmp = Float64(x * Float64(y + z)); 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.2e+24) tmp = t_0; elseif (x <= -3.2e-15) tmp = x * y; elseif (x <= 1.6e-29) tmp = z; elseif (x <= 2.25e+29) tmp = x * (y + z); 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.2e+24], t$95$0, If[LessEqual[x, -3.2e-15], N[(x * y), $MachinePrecision], If[LessEqual[x, 1.6e-29], z, If[LessEqual[x, 2.25e+29], N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{+24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-15}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-29}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+29}:\\
\;\;\;\;x \cdot \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.2e24 or 2.2500000000000001e29 < x Initial program 94.5%
Taylor expanded in y around 0 63.5%
Taylor expanded in x around inf 63.5%
associate-*r*63.5%
mul-1-neg63.5%
Simplified63.5%
if -1.2e24 < x < -3.1999999999999999e-15Initial program 99.7%
Taylor expanded in y around inf 67.8%
if -3.1999999999999999e-15 < x < 1.6e-29Initial program 100.0%
Taylor expanded in x around 0 77.2%
if 1.6e-29 < x < 2.2500000000000001e29Initial program 100.0%
Taylor expanded in x around inf 81.7%
neg-mul-181.7%
+-commutative81.7%
unsub-neg81.7%
Simplified81.7%
sub-neg81.7%
mul-1-neg81.7%
+-commutative81.7%
add-log-exp12.1%
*-un-lft-identity12.1%
log-prod12.1%
metadata-eval12.1%
add-log-exp81.7%
*-commutative81.7%
add-sqr-sqrt17.8%
sqrt-unprod74.8%
mul-1-neg74.8%
mul-1-neg74.8%
sqr-neg74.8%
sqrt-unprod56.9%
add-sqr-sqrt72.5%
Applied egg-rr72.5%
+-lft-identity72.5%
Simplified72.5%
Final simplification70.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))))
(if (<= x -1.05e+24)
t_0
(if (<= x -6.5e-12)
(* x y)
(if (<= x 2.7e-30) z (if (<= x 2e+36) (* x y) t_0))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (x <= -1.05e+24) {
tmp = t_0;
} else if (x <= -6.5e-12) {
tmp = x * y;
} else if (x <= 2.7e-30) {
tmp = z;
} else if (x <= 2e+36) {
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.05d+24)) then
tmp = t_0
else if (x <= (-6.5d-12)) then
tmp = x * y
else if (x <= 2.7d-30) then
tmp = z
else if (x <= 2d+36) 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.05e+24) {
tmp = t_0;
} else if (x <= -6.5e-12) {
tmp = x * y;
} else if (x <= 2.7e-30) {
tmp = z;
} else if (x <= 2e+36) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if x <= -1.05e+24: tmp = t_0 elif x <= -6.5e-12: tmp = x * y elif x <= 2.7e-30: tmp = z elif x <= 2e+36: tmp = x * y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (x <= -1.05e+24) tmp = t_0; elseif (x <= -6.5e-12) tmp = Float64(x * y); elseif (x <= 2.7e-30) tmp = z; elseif (x <= 2e+36) 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.05e+24) tmp = t_0; elseif (x <= -6.5e-12) tmp = x * y; elseif (x <= 2.7e-30) tmp = z; elseif (x <= 2e+36) 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.05e+24], t$95$0, If[LessEqual[x, -6.5e-12], N[(x * y), $MachinePrecision], If[LessEqual[x, 2.7e-30], z, If[LessEqual[x, 2e+36], N[(x * y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{+24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-12}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-30}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+36}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.0500000000000001e24 or 2.00000000000000008e36 < x Initial program 94.5%
Taylor expanded in y around 0 63.5%
Taylor expanded in x around inf 63.5%
associate-*r*63.5%
mul-1-neg63.5%
Simplified63.5%
if -1.0500000000000001e24 < x < -6.5000000000000002e-12 or 2.69999999999999987e-30 < x < 2.00000000000000008e36Initial program 99.8%
Taylor expanded in y around inf 69.9%
if -6.5000000000000002e-12 < x < 2.69999999999999987e-30Initial program 100.0%
Taylor expanded in x around 0 77.2%
Final simplification70.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -16500000000.0) (not (<= x 1.2e-29))) (* x (- y z)) (* z (- 1.0 x))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -16500000000.0) || !(x <= 1.2e-29)) {
tmp = x * (y - z);
} else {
tmp = z * (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) :: tmp
if ((x <= (-16500000000.0d0)) .or. (.not. (x <= 1.2d-29))) then
tmp = x * (y - z)
else
tmp = z * (1.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -16500000000.0) || !(x <= 1.2e-29)) {
tmp = x * (y - z);
} else {
tmp = z * (1.0 - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -16500000000.0) or not (x <= 1.2e-29): tmp = x * (y - z) else: tmp = z * (1.0 - x) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -16500000000.0) || !(x <= 1.2e-29)) tmp = Float64(x * Float64(y - z)); else tmp = Float64(z * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -16500000000.0) || ~((x <= 1.2e-29))) tmp = x * (y - z); else tmp = z * (1.0 - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -16500000000.0], N[Not[LessEqual[x, 1.2e-29]], $MachinePrecision]], N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16500000000 \lor \neg \left(x \leq 1.2 \cdot 10^{-29}\right):\\
\;\;\;\;x \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1.65e10 or 1.19999999999999996e-29 < x Initial program 95.4%
Taylor expanded in x around inf 98.2%
neg-mul-198.2%
+-commutative98.2%
unsub-neg98.2%
Simplified98.2%
if -1.65e10 < x < 1.19999999999999996e-29Initial program 100.0%
Taylor expanded in y around 0 76.3%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -16500000000.0) (not (<= x 3.4e-31))) (* x (- y z)) (- z (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -16500000000.0) || !(x <= 3.4e-31)) {
tmp = x * (y - z);
} else {
tmp = z - (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 <= (-16500000000.0d0)) .or. (.not. (x <= 3.4d-31))) then
tmp = x * (y - z)
else
tmp = z - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -16500000000.0) || !(x <= 3.4e-31)) {
tmp = x * (y - z);
} else {
tmp = z - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -16500000000.0) or not (x <= 3.4e-31): tmp = x * (y - z) else: tmp = z - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -16500000000.0) || !(x <= 3.4e-31)) tmp = Float64(x * Float64(y - z)); else tmp = Float64(z - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -16500000000.0) || ~((x <= 3.4e-31))) tmp = x * (y - z); else tmp = z - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -16500000000.0], N[Not[LessEqual[x, 3.4e-31]], $MachinePrecision]], N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(z - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16500000000 \lor \neg \left(x \leq 3.4 \cdot 10^{-31}\right):\\
\;\;\;\;x \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;z - x \cdot z\\
\end{array}
\end{array}
if x < -1.65e10 or 3.4000000000000001e-31 < x Initial program 95.4%
Taylor expanded in x around inf 98.2%
neg-mul-198.2%
+-commutative98.2%
unsub-neg98.2%
Simplified98.2%
if -1.65e10 < x < 3.4000000000000001e-31Initial program 100.0%
Taylor expanded in y around 0 76.3%
Taylor expanded in x around 0 76.3%
mul-1-neg76.3%
distribute-rgt-neg-out76.3%
+-commutative76.3%
distribute-rgt-neg-out76.3%
unsub-neg76.3%
Simplified76.3%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (<= x -2.25e-14) (* x y) (if (<= x 5.2e-31) z (* x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.25e-14) {
tmp = x * y;
} else if (x <= 5.2e-31) {
tmp = z;
} else {
tmp = 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 <= (-2.25d-14)) then
tmp = x * y
else if (x <= 5.2d-31) then
tmp = z
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.25e-14) {
tmp = x * y;
} else if (x <= 5.2e-31) {
tmp = z;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.25e-14: tmp = x * y elif x <= 5.2e-31: tmp = z else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.25e-14) tmp = Float64(x * y); elseif (x <= 5.2e-31) tmp = z; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.25e-14) tmp = x * y; elseif (x <= 5.2e-31) tmp = z; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.25e-14], N[(x * y), $MachinePrecision], If[LessEqual[x, 5.2e-31], z, N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.25 \cdot 10^{-14}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-31}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -2.2499999999999999e-14 or 5.19999999999999991e-31 < x Initial program 95.6%
Taylor expanded in y around inf 49.1%
if -2.2499999999999999e-14 < x < 5.19999999999999991e-31Initial program 100.0%
Taylor expanded in x around 0 77.2%
Final simplification62.0%
(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 97.6%
Taylor expanded in x around 0 100.0%
Taylor expanded in z around 0 97.6%
*-commutative97.6%
neg-mul-197.6%
distribute-lft-in97.6%
*-rgt-identity97.6%
associate-+l+97.6%
+-commutative97.6%
distribute-rgt-neg-out97.6%
unsub-neg97.6%
distribute-rgt-out--100.0%
Simplified100.0%
Final simplification100.0%
(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 97.6%
Taylor expanded in x around 0 38.0%
Final simplification38.0%
herbie shell --seed 2023221
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
:precision binary64
(+ (* x y) (* (- 1.0 x) z)))