
(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 8 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 (sin y) x (* z (cos y))))
double code(double x, double y, double z) {
return fma(sin(y), x, (z * cos(y)));
}
function code(x, y, z) return fma(sin(y), x, Float64(z * cos(y))) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * x + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin y, x, z \cdot \cos y\right)
\end{array}
Initial program 99.8%
Applied egg-rr0
(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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))) (t_1 (* x (sin y))))
(if (<= y -8.2e+89)
t_0
(if (<= y -27000000.0)
t_1
(if (<= y -7.5e-7)
t_0
(if (<= y 57.0)
(+
(*
x
(*
y
(+
1.0
(*
(* y y)
(+
-0.16666666666666666
(*
(* y y)
(+
0.008333333333333333
(* (* y y) -0.0001984126984126984))))))))
z)
t_1))))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double t_1 = x * sin(y);
double tmp;
if (y <= -8.2e+89) {
tmp = t_0;
} else if (y <= -27000000.0) {
tmp = t_1;
} else if (y <= -7.5e-7) {
tmp = t_0;
} else if (y <= 57.0) {
tmp = (x * (y * (1.0 + ((y * y) * (-0.16666666666666666 + ((y * y) * (0.008333333333333333 + ((y * y) * -0.0001984126984126984)))))))) + z;
} else {
tmp = t_1;
}
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 = z * cos(y)
t_1 = x * sin(y)
if (y <= (-8.2d+89)) then
tmp = t_0
else if (y <= (-27000000.0d0)) then
tmp = t_1
else if (y <= (-7.5d-7)) then
tmp = t_0
else if (y <= 57.0d0) then
tmp = (x * (y * (1.0d0 + ((y * y) * ((-0.16666666666666666d0) + ((y * y) * (0.008333333333333333d0 + ((y * y) * (-0.0001984126984126984d0))))))))) + z
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double t_1 = x * Math.sin(y);
double tmp;
if (y <= -8.2e+89) {
tmp = t_0;
} else if (y <= -27000000.0) {
tmp = t_1;
} else if (y <= -7.5e-7) {
tmp = t_0;
} else if (y <= 57.0) {
tmp = (x * (y * (1.0 + ((y * y) * (-0.16666666666666666 + ((y * y) * (0.008333333333333333 + ((y * y) * -0.0001984126984126984)))))))) + z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) t_1 = x * math.sin(y) tmp = 0 if y <= -8.2e+89: tmp = t_0 elif y <= -27000000.0: tmp = t_1 elif y <= -7.5e-7: tmp = t_0 elif y <= 57.0: tmp = (x * (y * (1.0 + ((y * y) * (-0.16666666666666666 + ((y * y) * (0.008333333333333333 + ((y * y) * -0.0001984126984126984)))))))) + z else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) t_1 = Float64(x * sin(y)) tmp = 0.0 if (y <= -8.2e+89) tmp = t_0; elseif (y <= -27000000.0) tmp = t_1; elseif (y <= -7.5e-7) tmp = t_0; elseif (y <= 57.0) tmp = Float64(Float64(x * Float64(y * Float64(1.0 + Float64(Float64(y * y) * Float64(-0.16666666666666666 + Float64(Float64(y * y) * Float64(0.008333333333333333 + Float64(Float64(y * y) * -0.0001984126984126984)))))))) + z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); t_1 = x * sin(y); tmp = 0.0; if (y <= -8.2e+89) tmp = t_0; elseif (y <= -27000000.0) tmp = t_1; elseif (y <= -7.5e-7) tmp = t_0; elseif (y <= 57.0) tmp = (x * (y * (1.0 + ((y * y) * (-0.16666666666666666 + ((y * y) * (0.008333333333333333 + ((y * y) * -0.0001984126984126984)))))))) + z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.2e+89], t$95$0, If[LessEqual[y, -27000000.0], t$95$1, If[LessEqual[y, -7.5e-7], t$95$0, If[LessEqual[y, 57.0], N[(N[(x * N[(y * N[(1.0 + N[(N[(y * y), $MachinePrecision] * N[(-0.16666666666666666 + N[(N[(y * y), $MachinePrecision] * N[(0.008333333333333333 + N[(N[(y * y), $MachinePrecision] * -0.0001984126984126984), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
t_1 := x \cdot \sin y\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -27000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -7.5 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 57:\\
\;\;\;\;x \cdot \left(y \cdot \left(1 + \left(y \cdot y\right) \cdot \left(-0.16666666666666666 + \left(y \cdot y\right) \cdot \left(0.008333333333333333 + \left(y \cdot y\right) \cdot -0.0001984126984126984\right)\right)\right)\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -8.1999999999999997e89 or -2.7e7 < y < -7.5000000000000002e-7Initial program 99.7%
Taylor expanded in x around 0 0
Simplified0
if -8.1999999999999997e89 < y < -2.7e7 or 57 < y Initial program 99.6%
Taylor expanded in x around inf 0
Simplified0
if -7.5000000000000002e-7 < y < 57Initial program 100.0%
Taylor expanded in y around 0 0
Simplified0
Taylor expanded in y around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (* x (sin y)) z))) (if (<= x -3.4e-47) t_0 (if (<= x 1.6e-50) (* z (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (x * sin(y)) + z;
double tmp;
if (x <= -3.4e-47) {
tmp = t_0;
} else if (x <= 1.6e-50) {
tmp = z * cos(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 * sin(y)) + z
if (x <= (-3.4d-47)) then
tmp = t_0
else if (x <= 1.6d-50) then
tmp = z * cos(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 * Math.sin(y)) + z;
double tmp;
if (x <= -3.4e-47) {
tmp = t_0;
} else if (x <= 1.6e-50) {
tmp = z * Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * math.sin(y)) + z tmp = 0 if x <= -3.4e-47: tmp = t_0 elif x <= 1.6e-50: tmp = z * math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * sin(y)) + z) tmp = 0.0 if (x <= -3.4e-47) tmp = t_0; elseif (x <= 1.6e-50) tmp = Float64(z * cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * sin(y)) + z; tmp = 0.0; if (x <= -3.4e-47) tmp = t_0; elseif (x <= 1.6e-50) tmp = z * cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[x, -3.4e-47], t$95$0, If[LessEqual[x, 1.6e-50], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y + z\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{-47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-50}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.4000000000000002e-47 or 1.6e-50 < x Initial program 99.8%
Taylor expanded in y around 0 0
Simplified0
if -3.4000000000000002e-47 < x < 1.6e-50Initial program 99.8%
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (sin y))))
(if (<= y -4000000.0)
t_0
(if (<= y 0.036)
(+ z (* y (+ x (* y (+ (* z -0.5) (* (* y x) -0.16666666666666666))))))
t_0))))
double code(double x, double y, double z) {
double t_0 = x * sin(y);
double tmp;
if (y <= -4000000.0) {
tmp = t_0;
} else if (y <= 0.036) {
tmp = z + (y * (x + (y * ((z * -0.5) + ((y * x) * -0.16666666666666666)))));
} 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 * sin(y)
if (y <= (-4000000.0d0)) then
tmp = t_0
else if (y <= 0.036d0) then
tmp = z + (y * (x + (y * ((z * (-0.5d0)) + ((y * x) * (-0.16666666666666666d0))))))
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 tmp;
if (y <= -4000000.0) {
tmp = t_0;
} else if (y <= 0.036) {
tmp = z + (y * (x + (y * ((z * -0.5) + ((y * x) * -0.16666666666666666)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.sin(y) tmp = 0 if y <= -4000000.0: tmp = t_0 elif y <= 0.036: tmp = z + (y * (x + (y * ((z * -0.5) + ((y * x) * -0.16666666666666666))))) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * sin(y)) tmp = 0.0 if (y <= -4000000.0) tmp = t_0; elseif (y <= 0.036) tmp = Float64(z + Float64(y * Float64(x + Float64(y * Float64(Float64(z * -0.5) + Float64(Float64(y * x) * -0.16666666666666666)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * sin(y); tmp = 0.0; if (y <= -4000000.0) tmp = t_0; elseif (y <= 0.036) tmp = z + (y * (x + (y * ((z * -0.5) + ((y * x) * -0.16666666666666666))))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4000000.0], t$95$0, If[LessEqual[y, 0.036], N[(z + N[(y * N[(x + N[(y * N[(N[(z * -0.5), $MachinePrecision] + N[(N[(y * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \sin y\\
\mathbf{if}\;y \leq -4000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.036:\\
\;\;\;\;z + y \cdot \left(x + y \cdot \left(z \cdot -0.5 + \left(y \cdot x\right) \cdot -0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4e6 or 0.0359999999999999973 < y Initial program 99.7%
Taylor expanded in x around inf 0
Simplified0
if -4e6 < y < 0.0359999999999999973Initial program 99.9%
Taylor expanded in y around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (if (<= x 5e+108) z (* x y)))
double code(double x, double y, double z) {
double tmp;
if (x <= 5e+108) {
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 <= 5d+108) 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 <= 5e+108) {
tmp = z;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 5e+108: tmp = z else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= 5e+108) tmp = z; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 5e+108) tmp = z; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 5e+108], z, N[(x * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+108}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < 4.99999999999999991e108Initial program 99.8%
Taylor expanded in y around 0 0
Simplified0
if 4.99999999999999991e108 < x Initial program 99.9%
Taylor expanded in y around 0 0
Simplified0
Taylor expanded in y around 0 0
Simplified0
Taylor expanded in y around inf 0
Simplified0
(FPCore (x y z) :precision binary64 (+ z (* y x)))
double code(double x, double y, double z) {
return z + (y * x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z + (y * x)
end function
public static double code(double x, double y, double z) {
return z + (y * x);
}
def code(x, y, z): return z + (y * x)
function code(x, y, z) return Float64(z + Float64(y * x)) end
function tmp = code(x, y, z) tmp = z + (y * x); end
code[x_, y_, z_] := N[(z + N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z + y \cdot x
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 0
Simplified0
(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 0
Simplified0
herbie shell --seed 2024110
(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))))