
(FPCore (x) :precision binary64 :pre TRUE (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)
use fmin_fmax_functions
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]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET t_0 = (sin((x * (5e-1)))) IN ((((8) / (3)) * t_0) * t_0) / (sin(x)) END code
\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}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 :pre TRUE (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)
use fmin_fmax_functions
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]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET t_0 = (sin((x * (5e-1)))) IN ((((8) / (3)) * t_0) * t_0) / (sin(x)) END code
\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}
(FPCore (x) :precision binary64 :pre TRUE (/ (tan (* -0.5 x)) -0.75))
double code(double x) {
return tan((-0.5 * x)) / -0.75;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = tan(((-0.5d0) * x)) / (-0.75d0)
end function
public static double code(double x) {
return Math.tan((-0.5 * x)) / -0.75;
}
def code(x): return math.tan((-0.5 * x)) / -0.75
function code(x) return Float64(tan(Float64(-0.5 * x)) / -0.75) end
function tmp = code(x) tmp = tan((-0.5 * x)) / -0.75; end
code[x_] := N[(N[Tan[N[(-0.5 * x), $MachinePrecision]], $MachinePrecision] / -0.75), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (tan(((-5e-1) * x))) / (-75e-2) END code
\frac{\tan \left(-0.5 \cdot x\right)}{-0.75}
Initial program 77.2%
Applied rewrites53.2%
Applied rewrites53.3%
Applied rewrites99.3%
Applied rewrites99.8%
(FPCore (x) :precision binary64 :pre TRUE (* (tan (* 0.5 x)) 1.3333333333333333))
double code(double x) {
return tan((0.5 * x)) * 1.3333333333333333;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = tan((0.5d0 * x)) * 1.3333333333333333d0
end function
public static double code(double x) {
return Math.tan((0.5 * x)) * 1.3333333333333333;
}
def code(x): return math.tan((0.5 * x)) * 1.3333333333333333
function code(x) return Float64(tan(Float64(0.5 * x)) * 1.3333333333333333) end
function tmp = code(x) tmp = tan((0.5 * x)) * 1.3333333333333333; end
code[x_] := N[(N[Tan[N[(0.5 * x), $MachinePrecision]], $MachinePrecision] * 1.3333333333333333), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (tan(((5e-1) * x))) * (13333333333333332593184650249895639717578887939453125e-52) END code
\tan \left(0.5 \cdot x\right) \cdot 1.3333333333333333
Initial program 77.2%
Applied rewrites53.3%
Applied rewrites53.2%
Applied rewrites99.4%
(FPCore (x) :precision binary64 :pre TRUE (* (/ (sin x) 2.0) 1.3333333333333333))
double code(double x) {
return (sin(x) / 2.0) * 1.3333333333333333;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (sin(x) / 2.0d0) * 1.3333333333333333d0
end function
public static double code(double x) {
return (Math.sin(x) / 2.0) * 1.3333333333333333;
}
def code(x): return (math.sin(x) / 2.0) * 1.3333333333333333
function code(x) return Float64(Float64(sin(x) / 2.0) * 1.3333333333333333) end
function tmp = code(x) tmp = (sin(x) / 2.0) * 1.3333333333333333; end
code[x_] := N[(N[(N[Sin[x], $MachinePrecision] / 2.0), $MachinePrecision] * 1.3333333333333333), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = ((sin(x)) / (2)) * (13333333333333332593184650249895639717578887939453125e-52) END code
\frac{\sin x}{2} \cdot 1.3333333333333333
Initial program 77.2%
Applied rewrites53.3%
Applied rewrites53.2%
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites58.7%
(FPCore (x)
:precision binary64
:pre TRUE
(/
1.0
(/
1.0
(/
x
(fma
(* x x)
(fma
(* x x)
(fma (* x x) -4.96031746031746e-5 -0.0020833333333333333)
-0.125)
1.5)))))double code(double x) {
return 1.0 / (1.0 / (x / fma((x * x), fma((x * x), fma((x * x), -4.96031746031746e-5, -0.0020833333333333333), -0.125), 1.5)));
}
function code(x) return Float64(1.0 / Float64(1.0 / Float64(x / fma(Float64(x * x), fma(Float64(x * x), fma(Float64(x * x), -4.96031746031746e-5, -0.0020833333333333333), -0.125), 1.5)))) end
code[x_] := N[(1.0 / N[(1.0 / N[(x / N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * -4.96031746031746e-5 + -0.0020833333333333333), $MachinePrecision] + -0.125), $MachinePrecision] + 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) / ((1) / (x / (((x * x) * (((x * x) * (((x * x) * (-49603174603174603131579278869622839920339174568653106689453125e-66)) + (-20833333333333333044212754003865484264679253101348876953125e-61))) + (-125e-3))) + (15e-1)))) END code
\frac{1}{\frac{1}{\frac{x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -4.96031746031746 \cdot 10^{-5}, -0.0020833333333333333\right), -0.125\right), 1.5\right)}}}
Initial program 77.2%
Applied rewrites53.2%
Taylor expanded in x around 0
Applied rewrites50.8%
Applied rewrites50.9%
(FPCore (x) :precision binary64 :pre TRUE (/ 1.0 (fma -0.125 x (/ 1.5 x))))
double code(double x) {
return 1.0 / fma(-0.125, x, (1.5 / x));
}
function code(x) return Float64(1.0 / fma(-0.125, x, Float64(1.5 / x))) end
code[x_] := N[(1.0 / N[(-0.125 * x + N[(1.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) / (((-125e-3) * x) + ((15e-1) / x)) END code
\frac{1}{\mathsf{fma}\left(-0.125, x, \frac{1.5}{x}\right)}
Initial program 77.2%
Applied rewrites53.2%
Taylor expanded in x around 0
Applied rewrites51.0%
Applied rewrites51.0%
Applied rewrites51.0%
(FPCore (x) :precision binary64 :pre TRUE (/ (/ 1.0 (/ 2.0 x)) 0.75))
double code(double x) {
return (1.0 / (2.0 / x)) / 0.75;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (1.0d0 / (2.0d0 / x)) / 0.75d0
end function
public static double code(double x) {
return (1.0 / (2.0 / x)) / 0.75;
}
def code(x): return (1.0 / (2.0 / x)) / 0.75
function code(x) return Float64(Float64(1.0 / Float64(2.0 / x)) / 0.75) end
function tmp = code(x) tmp = (1.0 / (2.0 / x)) / 0.75; end
code[x_] := N[(N[(1.0 / N[(2.0 / x), $MachinePrecision]), $MachinePrecision] / 0.75), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = ((1) / ((2) / x)) / (75e-2) END code
\frac{\frac{1}{\frac{2}{x}}}{0.75}
Initial program 77.2%
Applied rewrites53.3%
Applied rewrites53.2%
Taylor expanded in x around 0
Applied rewrites50.3%
Applied rewrites50.5%
(FPCore (x) :precision binary64 :pre TRUE (/ 1.0 (/ 1.0 (/ x 1.5))))
double code(double x) {
return 1.0 / (1.0 / (x / 1.5));
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 1.0d0 / (1.0d0 / (x / 1.5d0))
end function
public static double code(double x) {
return 1.0 / (1.0 / (x / 1.5));
}
def code(x): return 1.0 / (1.0 / (x / 1.5))
function code(x) return Float64(1.0 / Float64(1.0 / Float64(x / 1.5))) end
function tmp = code(x) tmp = 1.0 / (1.0 / (x / 1.5)); end
code[x_] := N[(1.0 / N[(1.0 / N[(x / 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) / ((1) / (x / (15e-1))) END code
\frac{1}{\frac{1}{\frac{x}{1.5}}}
Initial program 77.2%
Applied rewrites53.2%
Taylor expanded in x around 0
Applied rewrites50.4%
Applied rewrites50.5%
(FPCore (x) :precision binary64 :pre TRUE (/ 1.0 (/ 1.5 x)))
double code(double x) {
return 1.0 / (1.5 / x);
}
real(8) function code(x)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) / ((15e-1) / x) END code
\frac{1}{\frac{1.5}{x}}
Initial program 77.2%
Applied rewrites53.2%
Taylor expanded in x around 0
Applied rewrites50.4%
(FPCore (x) :precision binary64 :pre TRUE (* 0.6666666666666666 x))
double code(double x) {
return 0.6666666666666666 * x;
}
real(8) function code(x)
use fmin_fmax_functions
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]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (66666666666666662965923251249478198587894439697265625e-53) * x END code
0.6666666666666666 \cdot x
Initial program 77.2%
Taylor expanded in x around 0
Applied rewrites50.4%
herbie shell --seed 2026092
(FPCore (x)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
:precision binary64
(/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))