
(FPCore (x y z) :precision binary64 :pre TRUE (- (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) - (z * sin(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 * cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[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 * (cos(y))) - (z * (sin(y))) END code
x \cdot \cos y - z \cdot \sin y
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (- (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) - (z * sin(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 * cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[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 * (cos(y))) - (z * (sin(y))) END code
x \cdot \cos y - z \cdot \sin y
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (- (* x 1.0) (* z (sin y)))))
(if (<= z -1.5998878487717716e-87)
t_0
(if (<= z 1.3906905842088115e-61) (* x (cos y)) t_0))))double code(double x, double y, double z) {
double t_0 = (x * 1.0) - (z * sin(y));
double tmp;
if (z <= -1.5998878487717716e-87) {
tmp = t_0;
} else if (z <= 1.3906905842088115e-61) {
tmp = x * 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 * 1.0d0) - (z * sin(y))
if (z <= (-1.5998878487717716d-87)) then
tmp = t_0
else if (z <= 1.3906905842088115d-61) then
tmp = x * 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 * 1.0) - (z * Math.sin(y));
double tmp;
if (z <= -1.5998878487717716e-87) {
tmp = t_0;
} else if (z <= 1.3906905842088115e-61) {
tmp = x * Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 1.0) - (z * math.sin(y)) tmp = 0 if z <= -1.5998878487717716e-87: tmp = t_0 elif z <= 1.3906905842088115e-61: tmp = x * math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 1.0) - Float64(z * sin(y))) tmp = 0.0 if (z <= -1.5998878487717716e-87) tmp = t_0; elseif (z <= 1.3906905842088115e-61) tmp = Float64(x * cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 1.0) - (z * sin(y)); tmp = 0.0; if (z <= -1.5998878487717716e-87) tmp = t_0; elseif (z <= 1.3906905842088115e-61) tmp = x * cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.5998878487717716e-87], t$95$0, If[LessEqual[z, 1.3906905842088115e-61], N[(x * 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 * (1)) - (z * (sin(y)))) IN LET tmp_1 = IF (z <= (139069058420881154967487957630223034015355744194129779251587240099952514292987109389899646542932568675618170646032168982972712282179196417877818123690699010641669275401000049896538257598876953125e-255)) THEN (x * (cos(y))) ELSE t_0 ENDIF IN LET tmp = IF (z <= (-159988784877177164685523371169830722870522374072384409119026858684832480050318864005140114871679013601761552483193181404403016128515199488354968070059220853336754264519220820635743157089849151568897638446024723319315030689580225953250192105770111083984375e-341)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot 1 - z \cdot \sin y\\
\mathbf{if}\;z \leq -1.5998878487717716 \cdot 10^{-87}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.3906905842088115 \cdot 10^{-61}:\\
\;\;\;\;x \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -1.5998878487717716e-87 or 1.3906905842088115e-61 < z Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites77.3%
if -1.5998878487717716e-87 < z < 1.3906905842088115e-61Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites92.2%
Taylor expanded in x around inf
Applied rewrites61.0%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (cos y))))
(if (<= x -1.2014353339475216e-53)
t_0
(if (<= x 1.3907246641268288e-133) (- (* (sin y) z)) t_0))))double code(double x, double y, double z) {
double t_0 = x * cos(y);
double tmp;
if (x <= -1.2014353339475216e-53) {
tmp = t_0;
} else if (x <= 1.3907246641268288e-133) {
tmp = -(sin(y) * z);
} 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 * cos(y)
if (x <= (-1.2014353339475216d-53)) then
tmp = t_0
else if (x <= 1.3907246641268288d-133) then
tmp = -(sin(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 * Math.cos(y);
double tmp;
if (x <= -1.2014353339475216e-53) {
tmp = t_0;
} else if (x <= 1.3907246641268288e-133) {
tmp = -(Math.sin(y) * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.cos(y) tmp = 0 if x <= -1.2014353339475216e-53: tmp = t_0 elif x <= 1.3907246641268288e-133: tmp = -(math.sin(y) * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * cos(y)) tmp = 0.0 if (x <= -1.2014353339475216e-53) tmp = t_0; elseif (x <= 1.3907246641268288e-133) tmp = Float64(-Float64(sin(y) * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * cos(y); tmp = 0.0; if (x <= -1.2014353339475216e-53) tmp = t_0; elseif (x <= 1.3907246641268288e-133) tmp = -(sin(y) * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.2014353339475216e-53], t$95$0, If[LessEqual[x, 1.3907246641268288e-133], (-N[(N[Sin[y], $MachinePrecision] * z), $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 * (cos(y))) IN LET tmp_1 = IF (x <= (13907246641268287719553288589367698732274009277678938853341083963550402305825730272558285284260707557226592286720658421468340914383077588215032524302117800378662076704866440675793204111827833749549383931163536547600078549247750976353053708772891633938598045310131695191357079148094045872458853184477607279647119117250357415993544663024295005016028881072998046875e-494)) THEN (- ((sin(y)) * z)) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-1201435333947521567179383940228922831410793169252770766996959593329040310462231836384689301534482831918011668944531164721304996863097958037513990348088555037975311279296875e-224)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \cos y\\
\mathbf{if}\;x \leq -1.2014353339475216 \cdot 10^{-53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.3907246641268288 \cdot 10^{-133}:\\
\;\;\;\;-\sin y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -1.2014353339475216e-53 or 1.3907246641268288e-133 < x Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites92.2%
Taylor expanded in x around inf
Applied rewrites61.0%
if -1.2014353339475216e-53 < x < 1.3907246641268288e-133Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites40.4%
Applied rewrites40.4%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (cos y))))
(if (<= y -0.0037539651929508304)
t_0
(if (<= y 0.2681731775064146)
(+
x
(* y (- (* y (fma -0.5 x (* 0.16666666666666666 (* y z)))) z)))
t_0))))double code(double x, double y, double z) {
double t_0 = x * cos(y);
double tmp;
if (y <= -0.0037539651929508304) {
tmp = t_0;
} else if (y <= 0.2681731775064146) {
tmp = x + (y * ((y * fma(-0.5, x, (0.16666666666666666 * (y * z)))) - z));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * cos(y)) tmp = 0.0 if (y <= -0.0037539651929508304) tmp = t_0; elseif (y <= 0.2681731775064146) tmp = Float64(x + Float64(y * Float64(Float64(y * fma(-0.5, x, Float64(0.16666666666666666 * Float64(y * z)))) - z))); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.0037539651929508304], t$95$0, If[LessEqual[y, 0.2681731775064146], N[(x + N[(y * N[(N[(y * N[(-0.5 * x + N[(0.16666666666666666 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $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 * (cos(y))) IN LET tmp_1 = IF (y <= (268173177506414617266017330621252767741680145263671875e-54)) THEN (x + (y * ((y * (((-5e-1) * x) + ((1666666666666666574148081281236954964697360992431640625e-55) * (y * z)))) - z))) ELSE t_0 ENDIF IN LET tmp = IF (y <= (-37539651929508303929150514477441902272403240203857421875e-58)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \cos y\\
\mathbf{if}\;y \leq -0.0037539651929508304:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.2681731775064146:\\
\;\;\;\;x + y \cdot \left(y \cdot \mathsf{fma}\left(-0.5, x, 0.16666666666666666 \cdot \left(y \cdot z\right)\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -0.0037539651929508304 or 0.26817317750641462 < y Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites92.2%
Taylor expanded in x around inf
Applied rewrites61.0%
if -0.0037539651929508304 < y < 0.26817317750641462Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites51.5%
(FPCore (x y z) :precision binary64 :pre TRUE (- x (* z y)))
double code(double x, double y, double z) {
return x - (z * 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 - (z * y)
end function
public static double code(double x, double y, double z) {
return x - (z * y);
}
def code(x, y, z): return x - (z * y)
function code(x, y, z) return Float64(x - Float64(z * y)) end
function tmp = code(x, y, z) tmp = x - (z * y); end
code[x_, y_, z_] := N[(x - N[(z * y), $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 - (z * y) END code
x - z \cdot y
Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites52.7%
Applied rewrites52.7%
(FPCore (x y z) :precision binary64 :pre TRUE (* x 1.0))
double code(double x, double y, double z) {
return x * 1.0;
}
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 * 1.0d0
end function
public static double code(double x, double y, double z) {
return x * 1.0;
}
def code(x, y, z): return x * 1.0
function code(x, y, z) return Float64(x * 1.0) end
function tmp = code(x, y, z) tmp = x * 1.0; end
code[x_, y_, z_] := N[(x * 1.0), $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 * (1) END code
x \cdot 1
Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites92.2%
Taylor expanded in x around inf
Applied rewrites61.0%
Taylor expanded in y around 0
Applied rewrites39.5%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A"
:precision binary64
(- (* x (cos y)) (* z (sin y))))