
(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 7 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 (+ (* 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}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.45e+24) (not (<= z 1.02e+75))) (* z (cos y)) (+ (* x (sin y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.45e+24) || !(z <= 1.02e+75)) {
tmp = z * cos(y);
} else {
tmp = (x * sin(y)) + 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 <= (-3.45d+24)) .or. (.not. (z <= 1.02d+75))) then
tmp = z * cos(y)
else
tmp = (x * sin(y)) + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.45e+24) || !(z <= 1.02e+75)) {
tmp = z * Math.cos(y);
} else {
tmp = (x * Math.sin(y)) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.45e+24) or not (z <= 1.02e+75): tmp = z * math.cos(y) else: tmp = (x * math.sin(y)) + z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.45e+24) || !(z <= 1.02e+75)) tmp = Float64(z * cos(y)); else tmp = Float64(Float64(x * sin(y)) + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.45e+24) || ~((z <= 1.02e+75))) tmp = z * cos(y); else tmp = (x * sin(y)) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.45e+24], N[Not[LessEqual[z, 1.02e+75]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.45 \cdot 10^{+24} \lor \neg \left(z \leq 1.02 \cdot 10^{+75}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sin y + z\\
\end{array}
\end{array}
if z < -3.4500000000000001e24 or 1.0200000000000001e75 < z Initial program 99.9%
Taylor expanded in x around 0 90.7%
if -3.4500000000000001e24 < z < 1.0200000000000001e75Initial program 99.8%
Taylor expanded in y around 0 93.0%
Final simplification91.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.0026) (not (<= y 2.3e-29))) (* x (sin y)) (+ z (* x y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.0026) || !(y <= 2.3e-29)) {
tmp = x * sin(y);
} 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 ((y <= (-0.0026d0)) .or. (.not. (y <= 2.3d-29))) then
tmp = x * sin(y)
else
tmp = 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 <= 2.3e-29)) {
tmp = x * Math.sin(y);
} else {
tmp = z + (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.0026) or not (y <= 2.3e-29): tmp = x * math.sin(y) else: tmp = z + (x * y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.0026) || !(y <= 2.3e-29)) tmp = Float64(x * sin(y)); else tmp = Float64(z + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.0026) || ~((y <= 2.3e-29))) tmp = x * sin(y); else tmp = z + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.0026], N[Not[LessEqual[y, 2.3e-29]], $MachinePrecision]], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0026 \lor \neg \left(y \leq 2.3 \cdot 10^{-29}\right):\\
\;\;\;\;x \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;z + x \cdot y\\
\end{array}
\end{array}
if y < -0.0025999999999999999 or 2.29999999999999991e-29 < y Initial program 99.7%
Taylor expanded in x around inf 52.5%
if -0.0025999999999999999 < y < 2.29999999999999991e-29Initial program 100.0%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
Simplified100.0%
Final simplification73.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -7.4e-22) (not (<= z 8.6e+74))) (* z (cos y)) (* x (sin y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7.4e-22) || !(z <= 8.6e+74)) {
tmp = z * cos(y);
} else {
tmp = x * sin(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 ((z <= (-7.4d-22)) .or. (.not. (z <= 8.6d+74))) then
tmp = z * cos(y)
else
tmp = x * sin(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -7.4e-22) || !(z <= 8.6e+74)) {
tmp = z * Math.cos(y);
} else {
tmp = x * Math.sin(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7.4e-22) or not (z <= 8.6e+74): tmp = z * math.cos(y) else: tmp = x * math.sin(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7.4e-22) || !(z <= 8.6e+74)) tmp = Float64(z * cos(y)); else tmp = Float64(x * sin(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -7.4e-22) || ~((z <= 8.6e+74))) tmp = z * cos(y); else tmp = x * sin(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7.4e-22], N[Not[LessEqual[z, 8.6e+74]], $MachinePrecision]], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.4 \cdot 10^{-22} \lor \neg \left(z \leq 8.6 \cdot 10^{+74}\right):\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sin y\\
\end{array}
\end{array}
if z < -7.4e-22 or 8.60000000000000001e74 < z Initial program 99.8%
Taylor expanded in x around 0 88.4%
if -7.4e-22 < z < 8.60000000000000001e74Initial program 99.8%
Taylor expanded in x around inf 68.9%
Final simplification78.7%
(FPCore (x y z) :precision binary64 (if (<= x 2.7e+153) z (* x y)))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.7e+153) {
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.7d+153) 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.7e+153) {
tmp = z;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2.7e+153: tmp = z else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2.7e+153) tmp = z; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.7e+153) tmp = z; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2.7e+153], z, N[(x * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.7 \cdot 10^{+153}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < 2.7000000000000001e153Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt51.0%
associate-*r*51.0%
fma-def51.0%
Applied egg-rr51.0%
Taylor expanded in y around 0 40.6%
if 2.7000000000000001e153 < x Initial program 99.8%
Taylor expanded in y around 0 49.1%
+-commutative49.1%
Simplified49.1%
Taylor expanded in x around inf 37.7%
*-commutative37.7%
Simplified37.7%
Final simplification40.3%
(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 49.4%
+-commutative49.4%
Simplified49.4%
Final simplification49.4%
(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%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt51.2%
associate-*r*51.3%
fma-def51.3%
Applied egg-rr51.3%
Taylor expanded in y around 0 37.9%
Final simplification37.9%
herbie shell --seed 2024022
(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))))