
(FPCore (x y z) :precision binary64 (- (+ 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)
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]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ 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)
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]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (- (+ 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)
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]
\begin{array}{l}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -21.0) (not (<= z 7.2e-43))) (- (+ x 1.0) (* z (sin y))) (+ x (cos y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -21.0) || !(z <= 7.2e-43)) {
tmp = (x + 1.0) - (z * sin(y));
} else {
tmp = x + 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 ((z <= (-21.0d0)) .or. (.not. (z <= 7.2d-43))) then
tmp = (x + 1.0d0) - (z * sin(y))
else
tmp = x + cos(y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -21.0) || !(z <= 7.2e-43)) {
tmp = (x + 1.0) - (z * Math.sin(y));
} else {
tmp = x + Math.cos(y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -21.0) or not (z <= 7.2e-43): tmp = (x + 1.0) - (z * math.sin(y)) else: tmp = x + math.cos(y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -21.0) || !(z <= 7.2e-43)) tmp = Float64(Float64(x + 1.0) - Float64(z * sin(y))); else tmp = Float64(x + cos(y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -21.0) || ~((z <= 7.2e-43))) tmp = (x + 1.0) - (z * sin(y)); else tmp = x + cos(y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -21.0], N[Not[LessEqual[z, 7.2e-43]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -21 \lor \neg \left(z \leq 7.2 \cdot 10^{-43}\right):\\
\;\;\;\;\left(x + 1\right) - z \cdot \sin y\\
\mathbf{else}:\\
\;\;\;\;x + \cos y\\
\end{array}
\end{array}
if z < -21 or 7.1999999999999998e-43 < z Initial program 99.9%
Taylor expanded in y around 0 99.6%
if -21 < z < 7.1999999999999998e-43Initial program 100.0%
Taylor expanded in z around 0 99.4%
+-commutative99.4%
Simplified99.4%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (sin y) (- z))))
(if (<= z -4.8e+138)
t_0
(if (<= z -1.75e+35)
(+ 1.0 (- x (* y z)))
(if (<= z 2.2e+154) (+ x (cos y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) * -z;
double tmp;
if (z <= -4.8e+138) {
tmp = t_0;
} else if (z <= -1.75e+35) {
tmp = 1.0 + (x - (y * z));
} else if (z <= 2.2e+154) {
tmp = x + 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 = sin(y) * -z
if (z <= (-4.8d+138)) then
tmp = t_0
else if (z <= (-1.75d+35)) then
tmp = 1.0d0 + (x - (y * z))
else if (z <= 2.2d+154) 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 = Math.sin(y) * -z;
double tmp;
if (z <= -4.8e+138) {
tmp = t_0;
} else if (z <= -1.75e+35) {
tmp = 1.0 + (x - (y * z));
} else if (z <= 2.2e+154) {
tmp = x + Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) * -z tmp = 0 if z <= -4.8e+138: tmp = t_0 elif z <= -1.75e+35: tmp = 1.0 + (x - (y * z)) elif z <= 2.2e+154: tmp = x + math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(sin(y) * Float64(-z)) tmp = 0.0 if (z <= -4.8e+138) tmp = t_0; elseif (z <= -1.75e+35) tmp = Float64(1.0 + Float64(x - Float64(y * z))); elseif (z <= 2.2e+154) tmp = Float64(x + cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) * -z; tmp = 0.0; if (z <= -4.8e+138) tmp = t_0; elseif (z <= -1.75e+35) tmp = 1.0 + (x - (y * z)); elseif (z <= 2.2e+154) tmp = x + cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * (-z)), $MachinePrecision]}, If[LessEqual[z, -4.8e+138], t$95$0, If[LessEqual[z, -1.75e+35], N[(1.0 + N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.2e+154], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -4.8 \cdot 10^{+138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.75 \cdot 10^{+35}:\\
\;\;\;\;1 + \left(x - y \cdot z\right)\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+154}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -4.8000000000000002e138 or 2.2000000000000001e154 < z Initial program 99.8%
Taylor expanded in z around inf 72.7%
associate-*r*72.7%
neg-mul-172.7%
*-commutative72.7%
Simplified72.7%
if -4.8000000000000002e138 < z < -1.75e35Initial program 100.0%
Taylor expanded in y around 0 84.8%
mul-1-neg84.8%
unsub-neg84.8%
Simplified84.8%
if -1.75e35 < z < 2.2000000000000001e154Initial program 100.0%
Taylor expanded in z around 0 95.1%
+-commutative95.1%
Simplified95.1%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.00021) (not (<= y 1.6e+29))) (+ x (cos y)) (+ 1.0 (- x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.00021) || !(y <= 1.6e+29)) {
tmp = x + cos(y);
} else {
tmp = 1.0 + (x - (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 ((y <= (-0.00021d0)) .or. (.not. (y <= 1.6d+29))) then
tmp = x + cos(y)
else
tmp = 1.0d0 + (x - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.00021) || !(y <= 1.6e+29)) {
tmp = x + Math.cos(y);
} else {
tmp = 1.0 + (x - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.00021) or not (y <= 1.6e+29): tmp = x + math.cos(y) else: tmp = 1.0 + (x - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.00021) || !(y <= 1.6e+29)) tmp = Float64(x + cos(y)); else tmp = Float64(1.0 + Float64(x - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.00021) || ~((y <= 1.6e+29))) tmp = x + cos(y); else tmp = 1.0 + (x - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.00021], N[Not[LessEqual[y, 1.6e+29]], $MachinePrecision]], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.00021 \lor \neg \left(y \leq 1.6 \cdot 10^{+29}\right):\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - y \cdot z\right)\\
\end{array}
\end{array}
if y < -2.1000000000000001e-4 or 1.59999999999999993e29 < y Initial program 99.9%
Taylor expanded in z around 0 63.1%
+-commutative63.1%
Simplified63.1%
if -2.1000000000000001e-4 < y < 1.59999999999999993e29Initial program 100.0%
Taylor expanded in y around 0 97.8%
mul-1-neg97.8%
unsub-neg97.8%
Simplified97.8%
Final simplification81.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -6e+106) (not (<= y 7.5e+45))) (+ x 1.0) (+ 1.0 (- x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+106) || !(y <= 7.5e+45)) {
tmp = x + 1.0;
} else {
tmp = 1.0 + (x - (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 ((y <= (-6d+106)) .or. (.not. (y <= 7.5d+45))) then
tmp = x + 1.0d0
else
tmp = 1.0d0 + (x - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+106) || !(y <= 7.5e+45)) {
tmp = x + 1.0;
} else {
tmp = 1.0 + (x - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6e+106) or not (y <= 7.5e+45): tmp = x + 1.0 else: tmp = 1.0 + (x - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6e+106) || !(y <= 7.5e+45)) tmp = Float64(x + 1.0); else tmp = Float64(1.0 + Float64(x - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6e+106) || ~((y <= 7.5e+45))) tmp = x + 1.0; else tmp = 1.0 + (x - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6e+106], N[Not[LessEqual[y, 7.5e+45]], $MachinePrecision]], N[(x + 1.0), $MachinePrecision], N[(1.0 + N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+106} \lor \neg \left(y \leq 7.5 \cdot 10^{+45}\right):\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - y \cdot z\right)\\
\end{array}
\end{array}
if y < -6.0000000000000001e106 or 7.50000000000000058e45 < y Initial program 99.9%
Taylor expanded in y around 0 45.3%
if -6.0000000000000001e106 < y < 7.50000000000000058e45Initial program 100.0%
Taylor expanded in y around 0 85.1%
mul-1-neg85.1%
unsub-neg85.1%
Simplified85.1%
Final simplification70.3%
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
return x + 1.0;
}
real(8) function code(x, y, z)
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]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 61.8%
Final simplification61.8%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 42.9%
Final simplification42.9%
herbie shell --seed 2023308
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))