
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x * sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x * sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x * sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x * sin(y)) + (z * cos(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x * sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x * sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (fma x (sin y) (* z (cos y))))
double code(double x, double y, double z) {
return fma(x, sin(y), (z * cos(y)));
}
function code(x, y, z) return fma(x, sin(y), Float64(z * cos(y))) end
code[x_, y_, z_] := N[(x * N[Sin[y], $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)
\end{array}
Initial program 99.8%
fma-def99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (+ (* z (cos y)) (* x (sin y))))
double code(double x, double y, double z) {
return (z * cos(y)) + (x * sin(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (z * cos(y)) + (x * sin(y))
end function
public static double code(double x, double y, double z) {
return (z * Math.cos(y)) + (x * Math.sin(y));
}
def code(x, y, z): return (z * math.cos(y)) + (x * math.sin(y))
function code(x, y, z) return Float64(Float64(z * cos(y)) + Float64(x * sin(y))) end
function tmp = code(x, y, z) tmp = (z * cos(y)) + (x * sin(y)); end
code[x_, y_, z_] := N[(N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \cos y + x \cdot \sin y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (sin y))) (t_1 (* z (cos y))))
(if (<= y -2e+242)
t_0
(if (<= y -2.15e+162)
t_1
(if (<= y -2.2e+123)
t_0
(if (<= y -0.0022)
t_1
(if (<= y 7.5e-12)
(+ (* -0.5 (* z (* y y))) (+ z (* x y)))
(if (or (<= y 1.02e+78) (and (not (<= y 2e+160)) (<= y 1.4e+274)))
t_1
t_0))))))))
double code(double x, double y, double z) {
double t_0 = x * sin(y);
double t_1 = z * cos(y);
double tmp;
if (y <= -2e+242) {
tmp = t_0;
} else if (y <= -2.15e+162) {
tmp = t_1;
} else if (y <= -2.2e+123) {
tmp = t_0;
} else if (y <= -0.0022) {
tmp = t_1;
} else if (y <= 7.5e-12) {
tmp = (-0.5 * (z * (y * y))) + (z + (x * y));
} else if ((y <= 1.02e+78) || (!(y <= 2e+160) && (y <= 1.4e+274))) {
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 * sin(y)
t_1 = z * cos(y)
if (y <= (-2d+242)) then
tmp = t_0
else if (y <= (-2.15d+162)) then
tmp = t_1
else if (y <= (-2.2d+123)) then
tmp = t_0
else if (y <= (-0.0022d0)) then
tmp = t_1
else if (y <= 7.5d-12) then
tmp = ((-0.5d0) * (z * (y * y))) + (z + (x * y))
else if ((y <= 1.02d+78) .or. (.not. (y <= 2d+160)) .and. (y <= 1.4d+274)) 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 * Math.sin(y);
double t_1 = z * Math.cos(y);
double tmp;
if (y <= -2e+242) {
tmp = t_0;
} else if (y <= -2.15e+162) {
tmp = t_1;
} else if (y <= -2.2e+123) {
tmp = t_0;
} else if (y <= -0.0022) {
tmp = t_1;
} else if (y <= 7.5e-12) {
tmp = (-0.5 * (z * (y * y))) + (z + (x * y));
} else if ((y <= 1.02e+78) || (!(y <= 2e+160) && (y <= 1.4e+274))) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.sin(y) t_1 = z * math.cos(y) tmp = 0 if y <= -2e+242: tmp = t_0 elif y <= -2.15e+162: tmp = t_1 elif y <= -2.2e+123: tmp = t_0 elif y <= -0.0022: tmp = t_1 elif y <= 7.5e-12: tmp = (-0.5 * (z * (y * y))) + (z + (x * y)) elif (y <= 1.02e+78) or (not (y <= 2e+160) and (y <= 1.4e+274)): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * sin(y)) t_1 = Float64(z * cos(y)) tmp = 0.0 if (y <= -2e+242) tmp = t_0; elseif (y <= -2.15e+162) tmp = t_1; elseif (y <= -2.2e+123) tmp = t_0; elseif (y <= -0.0022) tmp = t_1; elseif (y <= 7.5e-12) tmp = Float64(Float64(-0.5 * Float64(z * Float64(y * y))) + Float64(z + Float64(x * y))); elseif ((y <= 1.02e+78) || (!(y <= 2e+160) && (y <= 1.4e+274))) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * sin(y); t_1 = z * cos(y); tmp = 0.0; if (y <= -2e+242) tmp = t_0; elseif (y <= -2.15e+162) tmp = t_1; elseif (y <= -2.2e+123) tmp = t_0; elseif (y <= -0.0022) tmp = t_1; elseif (y <= 7.5e-12) tmp = (-0.5 * (z * (y * y))) + (z + (x * y)); elseif ((y <= 1.02e+78) || (~((y <= 2e+160)) && (y <= 1.4e+274))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e+242], t$95$0, If[LessEqual[y, -2.15e+162], t$95$1, If[LessEqual[y, -2.2e+123], t$95$0, If[LessEqual[y, -0.0022], t$95$1, If[LessEqual[y, 7.5e-12], N[(N[(-0.5 * N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.02e+78], And[N[Not[LessEqual[y, 2e+160]], $MachinePrecision], LessEqual[y, 1.4e+274]]], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y\\
t_1 := z \cdot \cos y\\
\mathbf{if}\;y \leq -2 \cdot 10^{+242}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.15 \cdot 10^{+162}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.2 \cdot 10^{+123}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -0.0022:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-12}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \left(y \cdot y\right)\right) + \left(z + x \cdot y\right)\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+78} \lor \neg \left(y \leq 2 \cdot 10^{+160}\right) \land y \leq 1.4 \cdot 10^{+274}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.0000000000000001e242 or -2.1500000000000001e162 < y < -2.19999999999999992e123 or 1.01999999999999994e78 < y < 2.00000000000000001e160 or 1.40000000000000004e274 < y Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
add-sqr-sqrt59.3%
associate-*r*59.3%
fma-def59.3%
Applied egg-rr59.3%
fma-udef59.3%
associate-*r*59.3%
add-sqr-sqrt99.7%
*-commutative99.7%
+-commutative99.7%
add-cube-cbrt98.4%
unpow298.4%
associate-*r*98.3%
fma-udef98.3%
add-sqr-sqrt41.7%
pow241.7%
Applied egg-rr42.0%
unpow242.0%
add-sqr-sqrt99.7%
+-commutative99.7%
*-commutative99.7%
add-cube-cbrt99.2%
associate-*r*99.2%
fma-def99.2%
pow299.2%
*-commutative99.2%
Applied egg-rr99.2%
Taylor expanded in z around 0 73.9%
if -2.0000000000000001e242 < y < -2.1500000000000001e162 or -2.19999999999999992e123 < y < -0.00220000000000000013 or 7.5e-12 < y < 1.01999999999999994e78 or 2.00000000000000001e160 < y < 1.40000000000000004e274Initial program 99.6%
add-cube-cbrt99.3%
associate-*l*99.3%
fma-def99.3%
pow299.3%
Applied egg-rr99.3%
Taylor expanded in x around 0 73.2%
if -0.00220000000000000013 < y < 7.5e-12Initial program 100.0%
Taylor expanded in y around 0 100.0%
expm1-log1p-u96.7%
expm1-udef96.7%
*-commutative96.7%
unpow296.7%
associate-*r*96.7%
Applied egg-rr96.7%
expm1-def96.7%
expm1-log1p100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification86.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (sin y))) (t_1 (* z (cos y))))
(if (<= y -2.7e+242)
t_0
(if (<= y -2.35e+162)
t_1
(if (<= y -1.75e+118)
t_0
(if (<= y -2.1e-8)
t_1
(if (<= y 7.5e-12)
(fma y x z)
(if (or (<= y 3.55e+75)
(and (not (<= y 4.1e+164)) (<= y 2.8e+273)))
t_1
t_0))))))))
double code(double x, double y, double z) {
double t_0 = x * sin(y);
double t_1 = z * cos(y);
double tmp;
if (y <= -2.7e+242) {
tmp = t_0;
} else if (y <= -2.35e+162) {
tmp = t_1;
} else if (y <= -1.75e+118) {
tmp = t_0;
} else if (y <= -2.1e-8) {
tmp = t_1;
} else if (y <= 7.5e-12) {
tmp = fma(y, x, z);
} else if ((y <= 3.55e+75) || (!(y <= 4.1e+164) && (y <= 2.8e+273))) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * sin(y)) t_1 = Float64(z * cos(y)) tmp = 0.0 if (y <= -2.7e+242) tmp = t_0; elseif (y <= -2.35e+162) tmp = t_1; elseif (y <= -1.75e+118) tmp = t_0; elseif (y <= -2.1e-8) tmp = t_1; elseif (y <= 7.5e-12) tmp = fma(y, x, z); elseif ((y <= 3.55e+75) || (!(y <= 4.1e+164) && (y <= 2.8e+273))) tmp = t_1; else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.7e+242], t$95$0, If[LessEqual[y, -2.35e+162], t$95$1, If[LessEqual[y, -1.75e+118], t$95$0, If[LessEqual[y, -2.1e-8], t$95$1, If[LessEqual[y, 7.5e-12], N[(y * x + z), $MachinePrecision], If[Or[LessEqual[y, 3.55e+75], And[N[Not[LessEqual[y, 4.1e+164]], $MachinePrecision], LessEqual[y, 2.8e+273]]], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y\\
t_1 := z \cdot \cos y\\
\mathbf{if}\;y \leq -2.7 \cdot 10^{+242}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.35 \cdot 10^{+162}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{+118}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-8}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(y, x, z\right)\\
\mathbf{elif}\;y \leq 3.55 \cdot 10^{+75} \lor \neg \left(y \leq 4.1 \cdot 10^{+164}\right) \land y \leq 2.8 \cdot 10^{+273}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.69999999999999984e242 or -2.35000000000000001e162 < y < -1.75000000000000008e118 or 3.54999999999999991e75 < y < 4.10000000000000016e164 or 2.80000000000000018e273 < y Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
add-sqr-sqrt59.3%
associate-*r*59.3%
fma-def59.3%
Applied egg-rr59.3%
fma-udef59.3%
associate-*r*59.3%
add-sqr-sqrt99.7%
*-commutative99.7%
+-commutative99.7%
add-cube-cbrt98.4%
unpow298.4%
associate-*r*98.3%
fma-udef98.3%
add-sqr-sqrt41.7%
pow241.7%
Applied egg-rr42.0%
unpow242.0%
add-sqr-sqrt99.7%
+-commutative99.7%
*-commutative99.7%
add-cube-cbrt99.2%
associate-*r*99.2%
fma-def99.2%
pow299.2%
*-commutative99.2%
Applied egg-rr99.2%
Taylor expanded in z around 0 73.9%
if -2.69999999999999984e242 < y < -2.35000000000000001e162 or -1.75000000000000008e118 < y < -2.09999999999999994e-8 or 7.5e-12 < y < 3.54999999999999991e75 or 4.10000000000000016e164 < y < 2.80000000000000018e273Initial program 99.6%
add-cube-cbrt99.3%
associate-*l*99.3%
fma-def99.3%
pow299.3%
Applied egg-rr99.3%
Taylor expanded in x around 0 73.8%
if -2.09999999999999994e-8 < y < 7.5e-12Initial program 100.0%
Taylor expanded in y around 0 100.0%
fma-def100.0%
Simplified100.0%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.12e-72) (not (<= x 1.32e-33))) (+ z (* x (sin y))) (* z (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.12e-72) || !(x <= 1.32e-33)) {
tmp = z + (x * sin(y));
} else {
tmp = z * cos(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.12d-72)) .or. (.not. (x <= 1.32d-33))) then
tmp = z + (x * sin(y))
else
tmp = z * cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.12e-72) || !(x <= 1.32e-33)) {
tmp = z + (x * Math.sin(y));
} else {
tmp = z * Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.12e-72) or not (x <= 1.32e-33): tmp = z + (x * math.sin(y)) else: tmp = z * math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.12e-72) || !(x <= 1.32e-33)) tmp = Float64(z + Float64(x * sin(y))); else tmp = Float64(z * cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.12e-72) || ~((x <= 1.32e-33))) tmp = z + (x * sin(y)); else tmp = z * cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.12e-72], N[Not[LessEqual[x, 1.32e-33]], $MachinePrecision]], N[(z + N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{-72} \lor \neg \left(x \leq 1.32 \cdot 10^{-33}\right):\\
\;\;\;\;z + x \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \cos y\\
\end{array}
\end{array}
if x < -1.12000000000000005e-72 or 1.31999999999999993e-33 < x Initial program 99.8%
Taylor expanded in y around 0 88.6%
if -1.12000000000000005e-72 < x < 1.31999999999999993e-33Initial program 99.8%
add-cube-cbrt99.7%
associate-*l*99.7%
fma-def99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 90.9%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.0026) (not (<= y 7.5e-12))) (* z (cos y)) (+ (* -0.5 (* z (* y y))) (+ z (* x y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0026) || !(y <= 7.5e-12)) {
tmp = z * cos(y);
} else {
tmp = (-0.5 * (z * (y * y))) + (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 ((y <= (-0.0026d0)) .or. (.not. (y <= 7.5d-12))) then
tmp = z * cos(y)
else
tmp = ((-0.5d0) * (z * (y * y))) + (z + (x * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0026) || !(y <= 7.5e-12)) {
tmp = z * Math.cos(y);
} else {
tmp = (-0.5 * (z * (y * y))) + (z + (x * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.0026) or not (y <= 7.5e-12): tmp = z * math.cos(y) else: tmp = (-0.5 * (z * (y * y))) + (z + (x * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.0026) || !(y <= 7.5e-12)) tmp = Float64(z * cos(y)); else tmp = Float64(Float64(-0.5 * Float64(z * Float64(y * y))) + Float64(z + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.0026) || ~((y <= 7.5e-12))) tmp = z * cos(y); else tmp = (-0.5 * (z * (y * y))) + (z + (x * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.0026], N[Not[LessEqual[y, 7.5e-12]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0026 \lor \neg \left(y \leq 7.5 \cdot 10^{-12}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \left(y \cdot y\right)\right) + \left(z + x \cdot y\right)\\
\end{array}
\end{array}
if y < -0.0025999999999999999 or 7.5e-12 < y Initial program 99.6%
add-cube-cbrt98.9%
associate-*l*98.9%
fma-def98.9%
pow298.9%
Applied egg-rr98.9%
Taylor expanded in x around 0 55.1%
if -0.0025999999999999999 < y < 7.5e-12Initial program 100.0%
Taylor expanded in y around 0 100.0%
expm1-log1p-u96.7%
expm1-udef96.7%
*-commutative96.7%
unpow296.7%
associate-*r*96.7%
Applied egg-rr96.7%
expm1-def96.7%
expm1-log1p100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification76.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.26e-154) z (if (<= z 1.5e-191) (* x y) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.26e-154) {
tmp = z;
} else if (z <= 1.5e-191) {
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 (z <= (-1.26d-154)) then
tmp = z
else if (z <= 1.5d-191) 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 (z <= -1.26e-154) {
tmp = z;
} else if (z <= 1.5e-191) {
tmp = x * y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.26e-154: tmp = z elif z <= 1.5e-191: tmp = x * y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.26e-154) tmp = z; elseif (z <= 1.5e-191) tmp = Float64(x * y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.26e-154) tmp = z; elseif (z <= 1.5e-191) tmp = x * y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.26e-154], z, If[LessEqual[z, 1.5e-191], N[(x * y), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{-154}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-191}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.25999999999999994e-154 or 1.5e-191 < z Initial program 99.8%
Taylor expanded in y around 0 49.4%
Taylor expanded in y around 0 41.5%
if -1.25999999999999994e-154 < z < 1.5e-191Initial program 99.8%
Taylor expanded in y around 0 58.4%
Taylor expanded in y around inf 45.0%
Final simplification42.1%
(FPCore (x y z) :precision binary64 (+ z (* x y)))
double code(double x, double y, double z) {
return z + (x * y);
}
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)
end function
public static double code(double x, double y, double z) {
return z + (x * y);
}
def code(x, y, z): return z + (x * y)
function code(x, y, z) return Float64(z + Float64(x * y)) end
function tmp = code(x, y, z) tmp = z + (x * y); end
code[x_, y_, z_] := N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + x \cdot y
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 51.0%
Final simplification51.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 99.8%
Taylor expanded in y around 0 51.0%
Taylor expanded in y around 0 36.7%
Final simplification36.7%
herbie shell --seed 2023173
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
:precision binary64
(+ (* x (sin y)) (* z (cos y))))