| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 19976 |
(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_1 (pow t_0 2.0)))
(if (<= x -2e-8)
(/ 4.0 (/ (* (sin x) 1.5) t_1))
(if (<= x 5e-47) (/ t_0 0.75) (/ (/ t_1 0.375) (sin x))))))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));
double t_1 = pow(t_0, 2.0);
double tmp;
if (x <= -2e-8) {
tmp = 4.0 / ((sin(x) * 1.5) / t_1);
} else if (x <= 5e-47) {
tmp = t_0 / 0.75;
} else {
tmp = (t_1 / 0.375) / sin(x);
}
return tmp;
}
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
real(8) :: t_1
real(8) :: tmp
t_0 = sin((x * 0.5d0))
t_1 = t_0 ** 2.0d0
if (x <= (-2d-8)) then
tmp = 4.0d0 / ((sin(x) * 1.5d0) / t_1)
else if (x <= 5d-47) then
tmp = t_0 / 0.75d0
else
tmp = (t_1 / 0.375d0) / sin(x)
end if
code = tmp
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));
double t_1 = Math.pow(t_0, 2.0);
double tmp;
if (x <= -2e-8) {
tmp = 4.0 / ((Math.sin(x) * 1.5) / t_1);
} else if (x <= 5e-47) {
tmp = t_0 / 0.75;
} else {
tmp = (t_1 / 0.375) / Math.sin(x);
}
return tmp;
}
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)) t_1 = math.pow(t_0, 2.0) tmp = 0 if x <= -2e-8: tmp = 4.0 / ((math.sin(x) * 1.5) / t_1) elif x <= 5e-47: tmp = t_0 / 0.75 else: tmp = (t_1 / 0.375) / math.sin(x) return tmp
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)) t_1 = t_0 ^ 2.0 tmp = 0.0 if (x <= -2e-8) tmp = Float64(4.0 / Float64(Float64(sin(x) * 1.5) / t_1)); elseif (x <= 5e-47) tmp = Float64(t_0 / 0.75); else tmp = Float64(Float64(t_1 / 0.375) / sin(x)); end return tmp end
function tmp = code(x) tmp = (((8.0 / 3.0) * sin((x * 0.5))) * sin((x * 0.5))) / sin(x); end
function tmp_2 = code(x) t_0 = sin((x * 0.5)); t_1 = t_0 ^ 2.0; tmp = 0.0; if (x <= -2e-8) tmp = 4.0 / ((sin(x) * 1.5) / t_1); elseif (x <= 5e-47) tmp = t_0 / 0.75; else tmp = (t_1 / 0.375) / sin(x); end tmp_2 = tmp; 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]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, If[LessEqual[x, -2e-8], N[(4.0 / N[(N[(N[Sin[x], $MachinePrecision] * 1.5), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-47], N[(t$95$0 / 0.75), $MachinePrecision], N[(N[(t$95$1 / 0.375), $MachinePrecision] / N[Sin[x], $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)\\
t_1 := {t_0}^{2}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-8}:\\
\;\;\;\;\frac{4}{\frac{\sin x \cdot 1.5}{t_1}}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-47}:\\
\;\;\;\;\frac{t_0}{0.75}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1}{0.375}}{\sin x}\\
\end{array}
Results
| Original | 14.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if x < -2e-8Initial program 0.6
Simplified0.6
[Start]0.6 | \[ \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x}
\] |
|---|---|
rational.json-simplify-2 [=>]0.6 | \[ \frac{\color{blue}{\sin \left(x \cdot 0.5\right) \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right)}}{\sin x}
\] |
rational.json-simplify-43 [=>]0.6 | \[ \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}
\] |
rational.json-simplify-49 [=>]0.6 | \[ \color{blue}{\left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \frac{\frac{8}{3}}{\sin x}}
\] |
metadata-eval [=>]0.6 | \[ \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \frac{\color{blue}{2.6666666666666665}}{\sin x}
\] |
Taylor expanded in x around inf 0.6
Simplified0.6
[Start]0.6 | \[ {\sin \left(0.5 \cdot x\right)}^{2} \cdot \frac{2.6666666666666665}{\sin x}
\] |
|---|---|
rational.json-simplify-2 [<=]0.6 | \[ {\sin \color{blue}{\left(x \cdot 0.5\right)}}^{2} \cdot \frac{2.6666666666666665}{\sin x}
\] |
Applied egg-rr0.6
if -2e-8 < x < 5.00000000000000011e-47Initial program 31.3
Simplified0.3
[Start]31.3 | \[ \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x}
\] |
|---|---|
rational.json-simplify-49 [=>]0.3 | \[ \color{blue}{\sin \left(x \cdot 0.5\right) \cdot \frac{\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)}{\sin x}}
\] |
metadata-eval [=>]0.3 | \[ \sin \left(x \cdot 0.5\right) \cdot \frac{\color{blue}{2.6666666666666665} \cdot \sin \left(x \cdot 0.5\right)}{\sin x}
\] |
Applied egg-rr0.0
Applied egg-rr0.0
Simplified0.0
[Start]0.0 | \[ \frac{\sin \left(x \cdot 0.5\right)}{\frac{0.375}{\frac{\sin \left(x \cdot 0.5\right)}{\sin x}}} + 0
\] |
|---|---|
rational.json-simplify-4 [=>]0.0 | \[ \color{blue}{\frac{\sin \left(x \cdot 0.5\right)}{\frac{0.375}{\frac{\sin \left(x \cdot 0.5\right)}{\sin x}}}}
\] |
rational.json-simplify-61 [=>]0.0 | \[ \frac{\sin \left(x \cdot 0.5\right)}{\color{blue}{\frac{\sin x}{\frac{\sin \left(x \cdot 0.5\right)}{0.375}}}}
\] |
Taylor expanded in x around 0 0.0
if 5.00000000000000011e-47 < x Initial program 0.6
Simplified0.6
[Start]0.6 | \[ \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x}
\] |
|---|---|
rational.json-simplify-2 [=>]0.6 | \[ \frac{\color{blue}{\sin \left(x \cdot 0.5\right) \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right)}}{\sin x}
\] |
rational.json-simplify-43 [=>]0.6 | \[ \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}
\] |
rational.json-simplify-49 [=>]0.6 | \[ \color{blue}{\left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \frac{\frac{8}{3}}{\sin x}}
\] |
metadata-eval [=>]0.6 | \[ \left(\sin \left(x \cdot 0.5\right) \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \frac{\color{blue}{2.6666666666666665}}{\sin x}
\] |
Taylor expanded in x around inf 0.6
Simplified0.6
[Start]0.6 | \[ {\sin \left(0.5 \cdot x\right)}^{2} \cdot \frac{2.6666666666666665}{\sin x}
\] |
|---|---|
rational.json-simplify-2 [<=]0.6 | \[ {\sin \color{blue}{\left(x \cdot 0.5\right)}}^{2} \cdot \frac{2.6666666666666665}{\sin x}
\] |
Applied egg-rr0.5
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 19976 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 19976 |
| Alternative 3 | |
|---|---|
| Error | 0.3 |
| Cost | 19976 |
| Alternative 4 | |
|---|---|
| Error | 0.3 |
| Cost | 19976 |
| Alternative 5 | |
|---|---|
| Error | 0.3 |
| Cost | 19976 |
| Alternative 6 | |
|---|---|
| Error | 0.3 |
| Cost | 19904 |
| Alternative 7 | |
|---|---|
| Error | 0.5 |
| Cost | 19904 |
| Alternative 8 | |
|---|---|
| Error | 0.5 |
| Cost | 19904 |
| Alternative 9 | |
|---|---|
| Error | 0.5 |
| Cost | 19904 |
| Alternative 10 | |
|---|---|
| Error | 0.4 |
| Cost | 19904 |
| Alternative 11 | |
|---|---|
| Error | 0.3 |
| Cost | 19904 |
| Alternative 12 | |
|---|---|
| Error | 28.8 |
| Cost | 6720 |
| Alternative 13 | |
|---|---|
| Error | 28.7 |
| Cost | 6720 |
| Alternative 14 | |
|---|---|
| Error | 31.3 |
| Cost | 704 |
| Alternative 15 | |
|---|---|
| Error | 31.4 |
| Cost | 320 |
| Alternative 16 | |
|---|---|
| Error | 31.5 |
| Cost | 192 |
herbie shell --seed 2023074
(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)))