| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 6720 |
\[\tan \left(\frac{x}{2}\right) \cdot 1.3333333333333333
\]
(FPCore (x) :precision binary64 (/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ t_0 (/ (/ (sin x) t_0) 2.6666666666666665))))
double code(double x) {
return (((8.0 / 3.0) * sin((x * 0.5))) * sin((x * 0.5))) / sin(x);
}
double code(double x) {
double t_0 = sin((x * 0.5));
return t_0 / ((sin(x) / t_0) / 2.6666666666666665);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (((8.0d0 / 3.0d0) * sin((x * 0.5d0))) * sin((x * 0.5d0))) / sin(x)
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = t_0 / ((sin(x) / t_0) / 2.6666666666666665d0)
end function
public static double code(double x) {
return (((8.0 / 3.0) * Math.sin((x * 0.5))) * Math.sin((x * 0.5))) / Math.sin(x);
}
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return t_0 / ((Math.sin(x) / t_0) / 2.6666666666666665);
}
def code(x): return (((8.0 / 3.0) * math.sin((x * 0.5))) * math.sin((x * 0.5))) / math.sin(x)
def code(x): t_0 = math.sin((x * 0.5)) return t_0 / ((math.sin(x) / t_0) / 2.6666666666666665)
function code(x) return Float64(Float64(Float64(Float64(8.0 / 3.0) * sin(Float64(x * 0.5))) * sin(Float64(x * 0.5))) / sin(x)) end
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(t_0 / Float64(Float64(sin(x) / t_0) / 2.6666666666666665)) end
function tmp = code(x) tmp = (((8.0 / 3.0) * sin((x * 0.5))) * sin((x * 0.5))) / sin(x); end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = t_0 / ((sin(x) / t_0) / 2.6666666666666665); end
code[x_] := N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(t$95$0 / N[(N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision] / 2.6666666666666665), $MachinePrecision]), $MachinePrecision]]
\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x}
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{t_0}{\frac{\frac{\sin x}{t_0}}{2.6666666666666665}}
\end{array}
Results
| Original | 15.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
Initial program 15.1
Applied egg-rr0.5
Applied egg-rr0.3
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 6720 |
| Alternative 2 | |
|---|---|
| Error | 28.9 |
| Cost | 704 |
| Alternative 3 | |
|---|---|
| Error | 30.1 |
| Cost | 324 |
| Alternative 4 | |
|---|---|
| Error | 59.6 |
| Cost | 64 |

herbie shell --seed 2022225
(FPCore (x)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
:precision binary64
:herbie-target
(/ (/ (* 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)))