| 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 (/ (tan (* x 0.5)) 0.75))
double code(double x) {
return (((8.0 / 3.0) * sin((x * 0.5))) * sin((x * 0.5))) / sin(x);
}
double code(double x) {
return tan((x * 0.5)) / 0.75;
}
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
code = tan((x * 0.5d0)) / 0.75d0
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) {
return Math.tan((x * 0.5)) / 0.75;
}
def code(x): return (((8.0 / 3.0) * math.sin((x * 0.5))) * math.sin((x * 0.5))) / math.sin(x)
def code(x): return math.tan((x * 0.5)) / 0.75
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) return Float64(tan(Float64(x * 0.5)) / 0.75) 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) tmp = tan((x * 0.5)) / 0.75; 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_] := N[(N[Tan[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / 0.75), $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}
\frac{\tan \left(x \cdot 0.5\right)}{0.75}
Results
| Original | 15.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.1 |
Initial program 15.1
Simplified15.1
[Start]15.1 | \[ \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x}
\] |
|---|---|
associate-*l* [=>]15.1 | \[ \frac{\color{blue}{\frac{8}{3} \cdot \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right)}}{\sin x}
\] |
associate-*r/ [<=]15.1 | \[ \color{blue}{\frac{8}{3} \cdot \frac{\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x}}
\] |
*-commutative [<=]15.1 | \[ \color{blue}{\frac{\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \cdot \frac{8}{3}}
\] |
metadata-eval [=>]15.1 | \[ \frac{\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \cdot \color{blue}{2.6666666666666665}
\] |
Applied egg-rr40.0
Simplified30.1
[Start]40.0 | \[ e^{\mathsf{log1p}\left(\frac{\frac{\cos 0 - \cos x}{0.75}}{\sin x}\right)} - 1
\] |
|---|---|
expm1-def [=>]40.0 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{\cos 0 - \cos x}{0.75}}{\sin x}\right)\right)}
\] |
expm1-log1p [=>]30.1 | \[ \color{blue}{\frac{\frac{\cos 0 - \cos x}{0.75}}{\sin x}}
\] |
associate-/l/ [=>]30.1 | \[ \color{blue}{\frac{\cos 0 - \cos x}{\sin x \cdot 0.75}}
\] |
cos-0 [=>]30.1 | \[ \frac{\color{blue}{1} - \cos x}{\sin x \cdot 0.75}
\] |
Applied egg-rr0.3
Applied egg-rr0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 6720 |
| Alternative 2 | |
|---|---|
| Error | 31.3 |
| Cost | 704 |
| Alternative 3 | |
|---|---|
| Error | 31.6 |
| Cost | 320 |
| Alternative 4 | |
|---|---|
| Error | 31.5 |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Error | 31.6 |
| Cost | 192 |
herbie shell --seed 2023016
(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)))