
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* 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)
use fmin_fmax_functions
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]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * (sin(y))) + (z * (cos(y))) END code
x \cdot \sin y + z \cdot \cos y
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* 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)
use fmin_fmax_functions
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]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * (sin(y))) + (z * (cos(y))) END code
x \cdot \sin y + z \cdot \cos y
(FPCore (x y z) :precision binary64 :pre TRUE (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]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * (sin(y))) + (z * (cos(y))) END code
\mathsf{fma}\left(x, \sin y, z \cdot \cos y\right)
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (+ (* x (sin y)) z)))
(if (<= x -4.420245809256181e-50)
t_0
(if (<= x 2.3626467647767355e-51) (* z (cos y)) t_0))))double code(double x, double y, double z) {
double t_0 = (x * sin(y)) + z;
double tmp;
if (x <= -4.420245809256181e-50) {
tmp = t_0;
} else if (x <= 2.3626467647767355e-51) {
tmp = z * cos(y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
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 <= (-4.420245809256181d-50)) then
tmp = t_0
else if (x <= 2.3626467647767355d-51) 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 <= -4.420245809256181e-50) {
tmp = t_0;
} else if (x <= 2.3626467647767355e-51) {
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 <= -4.420245809256181e-50: tmp = t_0 elif x <= 2.3626467647767355e-51: 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 <= -4.420245809256181e-50) tmp = t_0; elseif (x <= 2.3626467647767355e-51) 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 <= -4.420245809256181e-50) tmp = t_0; elseif (x <= 2.3626467647767355e-51) 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, -4.420245809256181e-50], t$95$0, If[LessEqual[x, 2.3626467647767355e-51], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = ((x * (sin(y))) + z) IN LET tmp_1 = IF (x <= (236264676477673550497470444681180204913850868864713481278357873518707535048639999573918907749408215760656374148714740028348447824745048873040786929777823388576507568359375e-221)) THEN (z * (cos(y))) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-44202458092561807173146183805990310442416852708706562951185861630934021423055811815087956022190442979509568437286867776620587384972527189574975636787712574005126953125e-216)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \sin y + z\\
\mathbf{if}\;x \leq -4.420245809256181 \cdot 10^{-50}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.3626467647767355 \cdot 10^{-51}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -4.4202458092561807e-50 or 2.3626467647767355e-51 < x Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites76.7%
if -4.4202458092561807e-50 < x < 2.3626467647767355e-51Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites61.3%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (sin y))))
(if (<= x -5.303324118852423e+58)
t_0
(if (<= x 42163196947676.83) (* z (cos y)) t_0))))double code(double x, double y, double z) {
double t_0 = x * sin(y);
double tmp;
if (x <= -5.303324118852423e+58) {
tmp = t_0;
} else if (x <= 42163196947676.83) {
tmp = z * cos(y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
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 (x <= (-5.303324118852423d+58)) then
tmp = t_0
else if (x <= 42163196947676.83d0) 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);
double tmp;
if (x <= -5.303324118852423e+58) {
tmp = t_0;
} else if (x <= 42163196947676.83) {
tmp = z * Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.sin(y) tmp = 0 if x <= -5.303324118852423e+58: tmp = t_0 elif x <= 42163196947676.83: tmp = z * math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * sin(y)) tmp = 0.0 if (x <= -5.303324118852423e+58) tmp = t_0; elseif (x <= 42163196947676.83) 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); tmp = 0.0; if (x <= -5.303324118852423e+58) tmp = t_0; elseif (x <= 42163196947676.83) tmp = z * cos(y); 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[x, -5.303324118852423e+58], t$95$0, If[LessEqual[x, 42163196947676.83], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (sin(y))) IN LET tmp_1 = IF (x <= (42163196947676828125e-6)) THEN (z * (cos(y))) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-53033241188524230452986401087403946910043584422941378478080)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \sin y\\
\mathbf{if}\;x \leq -5.303324118852423 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 42163196947676.83:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -5.303324118852423e58 or 42163196947676.828 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites88.4%
Taylor expanded in x around inf
Applied rewrites40.2%
if -5.303324118852423e58 < x < 42163196947676.828Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites61.3%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (sin y))))
(if (<= y -0.03908848034999349)
t_0
(if (<= y 202.07469642451426)
(fma
x
y
(fma (* (fma -0.5 z (* (* y x) -0.16666666666666666)) y) y z))
t_0))))double code(double x, double y, double z) {
double t_0 = x * sin(y);
double tmp;
if (y <= -0.03908848034999349) {
tmp = t_0;
} else if (y <= 202.07469642451426) {
tmp = fma(x, y, fma((fma(-0.5, z, ((y * x) * -0.16666666666666666)) * y), y, z));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * sin(y)) tmp = 0.0 if (y <= -0.03908848034999349) tmp = t_0; elseif (y <= 202.07469642451426) tmp = fma(x, y, fma(Float64(fma(-0.5, z, Float64(Float64(y * x) * -0.16666666666666666)) * y), y, z)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.03908848034999349], t$95$0, If[LessEqual[y, 202.07469642451426], N[(x * y + N[(N[(N[(-0.5 * z + N[(N[(y * x), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * y + z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET t_0 = (x * (sin(y))) IN LET tmp_1 = IF (y <= (202074696424514257842020015232264995574951171875e-45)) THEN ((x * y) + ((((((-5e-1) * z) + ((y * x) * (-1666666666666666574148081281236954964697360992431640625e-55))) * y) * y) + z)) ELSE t_0 ENDIF IN LET tmp = IF (y <= (-390884803499934874171373166973353363573551177978515625e-55)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \sin y\\
\mathbf{if}\;y \leq -0.03908848034999349:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 202.07469642451426:\\
\;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(\mathsf{fma}\left(-0.5, z, \left(y \cdot x\right) \cdot -0.16666666666666666\right) \cdot y, y, z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -0.039088480349993487 or 202.07469642451426 < y Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites88.4%
Taylor expanded in x around inf
Applied rewrites40.2%
if -0.039088480349993487 < y < 202.07469642451426Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites51.5%
Applied rewrites51.5%
(FPCore (x y z) :precision binary64 :pre TRUE (fma y x z))
double code(double x, double y, double z) {
return fma(y, x, z);
}
function code(x, y, z) return fma(y, x, z) end
code[x_, y_, z_] := N[(y * x + z), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (y * x) + z END code
\mathsf{fma}\left(y, x, z\right)
Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites52.7%
Applied rewrites52.7%
(FPCore (x y z) :precision binary64 :pre TRUE (if (<= x 2.5388631714506055e+29) z (* x y)))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.5388631714506055e+29) {
tmp = z;
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 2.5388631714506055d+29) 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.5388631714506055e+29) {
tmp = z;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2.5388631714506055e+29: tmp = z else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2.5388631714506055e+29) tmp = z; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.5388631714506055e+29) tmp = z; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2.5388631714506055e+29], z, N[(x * y), $MachinePrecision]]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = LET tmp = IF (x <= (253886317145060547481221201920)) THEN z ELSE (x * y) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \leq 2.5388631714506055 \cdot 10^{+29}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if x < 2.5388631714506055e29Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites52.7%
Taylor expanded in x around 0
Applied rewrites39.3%
if 2.5388631714506055e29 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites88.4%
Taylor expanded in y around 0
Applied rewrites45.5%
Taylor expanded in x around inf
Applied rewrites17.1%
(FPCore (x y z) :precision binary64 :pre TRUE z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
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
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = z END code
z
Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites52.7%
Taylor expanded in x around 0
Applied rewrites39.3%
herbie shell --seed 2026092
(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))))