
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
double t_0 = sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / sin(x);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x): t_0 = math.sin((x * 0.5)) return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
double t_0 = sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / sin(x);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x): t_0 = math.sin((x * 0.5)) return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}
(FPCore (x) :precision binary64 (let* ((t_0 (sin (/ x 2.0)))) (/ t_0 (/ (/ (sin x) t_0) 2.6666666666666665))))
double code(double x) {
double t_0 = sin((x / 2.0));
return t_0 / ((sin(x) / t_0) / 2.6666666666666665);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x / 2.0d0))
code = t_0 / ((sin(x) / t_0) / 2.6666666666666665d0)
end function
public static double code(double x) {
double t_0 = Math.sin((x / 2.0));
return t_0 / ((Math.sin(x) / t_0) / 2.6666666666666665);
}
def code(x): t_0 = math.sin((x / 2.0)) return t_0 / ((math.sin(x) / t_0) / 2.6666666666666665)
function code(x) t_0 = sin(Float64(x / 2.0)) return Float64(t_0 / Float64(Float64(sin(x) / t_0) / 2.6666666666666665)) end
function tmp = code(x) t_0 = sin((x / 2.0)); tmp = t_0 / ((sin(x) / t_0) / 2.6666666666666665); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 / N[(N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision] / 2.6666666666666665), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{x}{2}\right)\\
\frac{t\_0}{\frac{\frac{\sin x}{t\_0}}{2.6666666666666665}}
\end{array}
\end{array}
Initial program 78.7%
Simplified0
Applied egg-rr0
Applied egg-rr0
(FPCore (x) :precision binary64 (* (tan (/ x 2.0)) 1.3333333333333333))
double code(double x) {
return tan((x / 2.0)) * 1.3333333333333333;
}
real(8) function code(x)
real(8), intent (in) :: x
code = tan((x / 2.0d0)) * 1.3333333333333333d0
end function
public static double code(double x) {
return Math.tan((x / 2.0)) * 1.3333333333333333;
}
def code(x): return math.tan((x / 2.0)) * 1.3333333333333333
function code(x) return Float64(tan(Float64(x / 2.0)) * 1.3333333333333333) end
function tmp = code(x) tmp = tan((x / 2.0)) * 1.3333333333333333; end
code[x_] := N[(N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision] * 1.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\tan \left(\frac{x}{2}\right) \cdot 1.3333333333333333
\end{array}
Initial program 78.7%
Simplified0
Applied egg-rr0
Applied egg-rr0
(FPCore (x) :precision binary64 (/ 1.0 (/ (+ 1.5 (* (* x x) -0.125)) x)))
double code(double x) {
return 1.0 / ((1.5 + ((x * x) * -0.125)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / ((1.5d0 + ((x * x) * (-0.125d0))) / x)
end function
public static double code(double x) {
return 1.0 / ((1.5 + ((x * x) * -0.125)) / x);
}
def code(x): return 1.0 / ((1.5 + ((x * x) * -0.125)) / x)
function code(x) return Float64(1.0 / Float64(Float64(1.5 + Float64(Float64(x * x) * -0.125)) / x)) end
function tmp = code(x) tmp = 1.0 / ((1.5 + ((x * x) * -0.125)) / x); end
code[x_] := N[(1.0 / N[(N[(1.5 + N[(N[(x * x), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1.5 + \left(x \cdot x\right) \cdot -0.125}{x}}
\end{array}
Initial program 78.7%
Simplified0
Applied egg-rr0
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
(FPCore (x) :precision binary64 (/ 1.0 (/ 1.5 x)))
double code(double x) {
return 1.0 / (1.5 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (1.5d0 / x)
end function
public static double code(double x) {
return 1.0 / (1.5 / x);
}
def code(x): return 1.0 / (1.5 / x)
function code(x) return Float64(1.0 / Float64(1.5 / x)) end
function tmp = code(x) tmp = 1.0 / (1.5 / x); end
code[x_] := N[(1.0 / N[(1.5 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1.5}{x}}
\end{array}
Initial program 78.7%
Simplified0
Applied egg-rr0
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
(FPCore (x) :precision binary64 (/ 0.6666666666666666 (/ 1.0 x)))
double code(double x) {
return 0.6666666666666666 / (1.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.6666666666666666d0 / (1.0d0 / x)
end function
public static double code(double x) {
return 0.6666666666666666 / (1.0 / x);
}
def code(x): return 0.6666666666666666 / (1.0 / x)
function code(x) return Float64(0.6666666666666666 / Float64(1.0 / x)) end
function tmp = code(x) tmp = 0.6666666666666666 / (1.0 / x); end
code[x_] := N[(0.6666666666666666 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.6666666666666666}{\frac{1}{x}}
\end{array}
Initial program 78.7%
Simplified0
Applied egg-rr0
Taylor expanded in x around 0 0
Simplified0
Taylor expanded in x around 0 0
Simplified0
Applied egg-rr0
(FPCore (x) :precision binary64 (* 0.6666666666666666 x))
double code(double x) {
return 0.6666666666666666 * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.6666666666666666d0 * x
end function
public static double code(double x) {
return 0.6666666666666666 * x;
}
def code(x): return 0.6666666666666666 * x
function code(x) return Float64(0.6666666666666666 * x) end
function tmp = code(x) tmp = 0.6666666666666666 * x; end
code[x_] := N[(0.6666666666666666 * x), $MachinePrecision]
\begin{array}{l}
\\
0.6666666666666666 \cdot x
\end{array}
Initial program 78.7%
Simplified0
Taylor expanded in x around 0 0
Simplified0
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (/ (* 8.0 t_0) 3.0) (/ (sin x) t_0))))
double code(double x) {
double t_0 = sin((x * 0.5));
return ((8.0 * t_0) / 3.0) / (sin(x) / t_0);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = ((8.0d0 * t_0) / 3.0d0) / (sin(x) / t_0)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return ((8.0 * t_0) / 3.0) / (Math.sin(x) / t_0);
}
def code(x): t_0 = math.sin((x * 0.5)) return ((8.0 * t_0) / 3.0) / (math.sin(x) / t_0)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(8.0 * t_0) / 3.0) / Float64(sin(x) / t_0)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = ((8.0 * t_0) / 3.0) / (sin(x) / t_0); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(8.0 * t$95$0), $MachinePrecision] / 3.0), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\frac{8 \cdot t\_0}{3}}{\frac{\sin x}{t\_0}}
\end{array}
\end{array}
herbie shell --seed 2024110
(FPCore (x)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
:precision binary64
:alt
(/ (/ (* 8.0 (sin (* x 0.5))) 3.0) (/ (sin x) (sin (* x 0.5))))
(/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))