Alternative 1 | |
---|---|
Error | 0.0 |
Cost | 13888 |
\[x \cdot \left(1.875 + \left(\left(x \cdot x\right) \cdot S\right) \cdot \left(\sqrt{0.375} \cdot \left(x \cdot x\right) - \sqrt{4.166666666666667}\right)\right)
\]
(FPCore (x S) :precision binary64 (* x (- (/ 15.0 8.0) (* (* S (pow x 2.0)) (- (sqrt (/ 25.0 6.0)) (* (sqrt (/ 3.0 8.0)) (pow x 2.0)))))))
(FPCore (x S) :precision binary64 (* x (+ 1.875 (* (/ x (/ 1.0 (* x S))) (- (* (sqrt 0.375) (* x x)) (sqrt 4.166666666666667))))))
double code(double x, double S) { return x * ((15.0 / 8.0) - ((S * pow(x, 2.0)) * (sqrt((25.0 / 6.0)) - (sqrt((3.0 / 8.0)) * pow(x, 2.0))))); }
double code(double x, double S) { return x * (1.875 + ((x / (1.0 / (x * S))) * ((sqrt(0.375) * (x * x)) - sqrt(4.166666666666667)))); }
real(8) function code(x, s) real(8), intent (in) :: x real(8), intent (in) :: s code = x * ((15.0d0 / 8.0d0) - ((s * (x ** 2.0d0)) * (sqrt((25.0d0 / 6.0d0)) - (sqrt((3.0d0 / 8.0d0)) * (x ** 2.0d0))))) end function
real(8) function code(x, s) real(8), intent (in) :: x real(8), intent (in) :: s code = x * (1.875d0 + ((x / (1.0d0 / (x * s))) * ((sqrt(0.375d0) * (x * x)) - sqrt(4.166666666666667d0)))) end function
public static double code(double x, double S) { return x * ((15.0 / 8.0) - ((S * Math.pow(x, 2.0)) * (Math.sqrt((25.0 / 6.0)) - (Math.sqrt((3.0 / 8.0)) * Math.pow(x, 2.0))))); }
public static double code(double x, double S) { return x * (1.875 + ((x / (1.0 / (x * S))) * ((Math.sqrt(0.375) * (x * x)) - Math.sqrt(4.166666666666667)))); }
def code(x, S): return x * ((15.0 / 8.0) - ((S * math.pow(x, 2.0)) * (math.sqrt((25.0 / 6.0)) - (math.sqrt((3.0 / 8.0)) * math.pow(x, 2.0)))))
def code(x, S): return x * (1.875 + ((x / (1.0 / (x * S))) * ((math.sqrt(0.375) * (x * x)) - math.sqrt(4.166666666666667))))
function code(x, S) return Float64(x * Float64(Float64(15.0 / 8.0) - Float64(Float64(S * (x ^ 2.0)) * Float64(sqrt(Float64(25.0 / 6.0)) - Float64(sqrt(Float64(3.0 / 8.0)) * (x ^ 2.0)))))) end
function code(x, S) return Float64(x * Float64(1.875 + Float64(Float64(x / Float64(1.0 / Float64(x * S))) * Float64(Float64(sqrt(0.375) * Float64(x * x)) - sqrt(4.166666666666667))))) end
function tmp = code(x, S) tmp = x * ((15.0 / 8.0) - ((S * (x ^ 2.0)) * (sqrt((25.0 / 6.0)) - (sqrt((3.0 / 8.0)) * (x ^ 2.0))))); end
function tmp = code(x, S) tmp = x * (1.875 + ((x / (1.0 / (x * S))) * ((sqrt(0.375) * (x * x)) - sqrt(4.166666666666667)))); end
code[x_, S_] := N[(x * N[(N[(15.0 / 8.0), $MachinePrecision] - N[(N[(S * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(25.0 / 6.0), $MachinePrecision]], $MachinePrecision] - N[(N[Sqrt[N[(3.0 / 8.0), $MachinePrecision]], $MachinePrecision] * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, S_] := N[(x * N[(1.875 + N[(N[(x / N[(1.0 / N[(x * S), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[0.375], $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] - N[Sqrt[4.166666666666667], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \left(\frac{15}{8} - \left(S \cdot {x}^{2}\right) \cdot \left(\sqrt{\frac{25}{6}} - \sqrt{\frac{3}{8}} \cdot {x}^{2}\right)\right)
x \cdot \left(1.875 + \frac{x}{\frac{1}{x \cdot S}} \cdot \left(\sqrt{0.375} \cdot \left(x \cdot x\right) - \sqrt{4.166666666666667}\right)\right)
Results
Initial program 0.0
Simplified0.0
[Start]0.0 | \[ x \cdot \left(\frac{15}{8} - \left(S \cdot {x}^{2}\right) \cdot \left(\sqrt{\frac{25}{6}} - \sqrt{\frac{3}{8}} \cdot {x}^{2}\right)\right)
\] |
---|---|
metadata-eval [=>]0.0 | \[ x \cdot \left(\color{blue}{1.875} - \left(S \cdot {x}^{2}\right) \cdot \left(\sqrt{\frac{25}{6}} - \sqrt{\frac{3}{8}} \cdot {x}^{2}\right)\right)
\] |
unpow2 [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \left(\sqrt{\frac{25}{6}} - \sqrt{\frac{3}{8}} \cdot {x}^{2}\right)\right)
\] |
sub-neg [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\left(\sqrt{\frac{25}{6}} + \left(-\sqrt{\frac{3}{8}} \cdot {x}^{2}\right)\right)}\right)
\] |
neg-mul-1 [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{\frac{25}{6}} + \color{blue}{-1 \cdot \left(\sqrt{\frac{3}{8}} \cdot {x}^{2}\right)}\right)\right)
\] |
*-commutative [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{\frac{25}{6}} + \color{blue}{\left(\sqrt{\frac{3}{8}} \cdot {x}^{2}\right) \cdot -1}\right)\right)
\] |
cancel-sign-sub [<=]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\left(\sqrt{\frac{25}{6}} - \left(-\sqrt{\frac{3}{8}} \cdot {x}^{2}\right) \cdot -1\right)}\right)
\] |
metadata-eval [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{\color{blue}{4.166666666666667}} - \left(-\sqrt{\frac{3}{8}} \cdot {x}^{2}\right) \cdot -1\right)\right)
\] |
*-commutative [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{4.166666666666667} - \color{blue}{-1 \cdot \left(-\sqrt{\frac{3}{8}} \cdot {x}^{2}\right)}\right)\right)
\] |
neg-mul-1 [<=]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{4.166666666666667} - \color{blue}{\left(-\left(-\sqrt{\frac{3}{8}} \cdot {x}^{2}\right)\right)}\right)\right)
\] |
remove-double-neg [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{4.166666666666667} - \color{blue}{\sqrt{\frac{3}{8}} \cdot {x}^{2}}\right)\right)
\] |
*-commutative [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{4.166666666666667} - \color{blue}{{x}^{2} \cdot \sqrt{\frac{3}{8}}}\right)\right)
\] |
unpow2 [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{4.166666666666667} - \color{blue}{\left(x \cdot x\right)} \cdot \sqrt{\frac{3}{8}}\right)\right)
\] |
metadata-eval [=>]0.0 | \[ x \cdot \left(1.875 - \left(S \cdot \left(x \cdot x\right)\right) \cdot \left(\sqrt{4.166666666666667} - \left(x \cdot x\right) \cdot \sqrt{\color{blue}{0.375}}\right)\right)
\] |
Applied egg-rr0.0
Simplified0.0
[Start]0.0 | \[ x \cdot \left(1.875 - \frac{x \cdot \left(x \cdot S\right)}{\frac{1}{\sqrt{4.166666666666667} - \left(x \cdot x\right) \cdot \sqrt{0.375}}}\right)
\] |
---|---|
associate-/r/ [=>]0.0 | \[ x \cdot \left(1.875 - \color{blue}{\frac{x \cdot \left(x \cdot S\right)}{1} \cdot \left(\sqrt{4.166666666666667} - \left(x \cdot x\right) \cdot \sqrt{0.375}\right)}\right)
\] |
*-commutative [=>]0.0 | \[ x \cdot \left(1.875 - \color{blue}{\left(\sqrt{4.166666666666667} - \left(x \cdot x\right) \cdot \sqrt{0.375}\right) \cdot \frac{x \cdot \left(x \cdot S\right)}{1}}\right)
\] |
*-commutative [=>]0.0 | \[ x \cdot \left(1.875 - \left(\sqrt{4.166666666666667} - \color{blue}{\sqrt{0.375} \cdot \left(x \cdot x\right)}\right) \cdot \frac{x \cdot \left(x \cdot S\right)}{1}\right)
\] |
associate-/l* [=>]0.0 | \[ x \cdot \left(1.875 - \left(\sqrt{4.166666666666667} - \sqrt{0.375} \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\frac{x}{\frac{1}{x \cdot S}}}\right)
\] |
Final simplification0.0
Alternative 1 | |
---|---|
Error | 0.0 |
Cost | 13888 |
Alternative 2 | |
---|---|
Error | 0.2 |
Cost | 7360 |
Alternative 3 | |
---|---|
Error | 0.3 |
Cost | 7104 |
herbie shell --seed 1
(FPCore (x S)
:name "x*(15/8-((S*x^2)*(sqrt(25/6)-(sqrt(3/8)*x^2))))"
:precision binary64
:pre (and (and (<= 0.0 x) (<= x 1000000000.0)) (and (<= 0.0 S) (<= S 1e+18)))
(* x (- (/ 15.0 8.0) (* (* S (pow x 2.0)) (- (sqrt (/ 25.0 6.0)) (* (sqrt (/ 3.0 8.0)) (pow x 2.0)))))))