Average Error: 0.1 → 0.1
Time: 1.4min
Precision: binary64
Cost: 7232
\[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
\[\left(1 + \frac{\frac{rand}{3}}{\sqrt{a + -0.3333333333333333}}\right) \cdot \left(a + -0.3333333333333333\right) \]
(FPCore (a rand)
 :precision binary64
 (*
  (- a (/ 1.0 3.0))
  (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 (- a (/ 1.0 3.0))))) rand))))
(FPCore (a rand)
 :precision binary64
 (*
  (+ 1.0 (/ (/ rand 3.0) (sqrt (+ a -0.3333333333333333))))
  (+ a -0.3333333333333333)))
double code(double a, double rand) {
	return (a - (1.0 / 3.0)) * (1.0 + ((1.0 / sqrt((9.0 * (a - (1.0 / 3.0))))) * rand));
}
double code(double a, double rand) {
	return (1.0 + ((rand / 3.0) / sqrt((a + -0.3333333333333333)))) * (a + -0.3333333333333333);
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (a - (1.0d0 / 3.0d0)) * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * (a - (1.0d0 / 3.0d0))))) * rand))
end function
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (1.0d0 + ((rand / 3.0d0) / sqrt((a + (-0.3333333333333333d0))))) * (a + (-0.3333333333333333d0))
end function
public static double code(double a, double rand) {
	return (a - (1.0 / 3.0)) * (1.0 + ((1.0 / Math.sqrt((9.0 * (a - (1.0 / 3.0))))) * rand));
}
public static double code(double a, double rand) {
	return (1.0 + ((rand / 3.0) / Math.sqrt((a + -0.3333333333333333)))) * (a + -0.3333333333333333);
}
def code(a, rand):
	return (a - (1.0 / 3.0)) * (1.0 + ((1.0 / math.sqrt((9.0 * (a - (1.0 / 3.0))))) * rand))
def code(a, rand):
	return (1.0 + ((rand / 3.0) / math.sqrt((a + -0.3333333333333333)))) * (a + -0.3333333333333333)
function code(a, rand)
	return Float64(Float64(a - Float64(1.0 / 3.0)) * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * Float64(a - Float64(1.0 / 3.0))))) * rand)))
end
function code(a, rand)
	return Float64(Float64(1.0 + Float64(Float64(rand / 3.0) / sqrt(Float64(a + -0.3333333333333333)))) * Float64(a + -0.3333333333333333))
end
function tmp = code(a, rand)
	tmp = (a - (1.0 / 3.0)) * (1.0 + ((1.0 / sqrt((9.0 * (a - (1.0 / 3.0))))) * rand));
end
function tmp = code(a, rand)
	tmp = (1.0 + ((rand / 3.0) / sqrt((a + -0.3333333333333333)))) * (a + -0.3333333333333333);
end
code[a_, rand_] := N[(N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[a_, rand_] := N[(N[(1.0 + N[(N[(rand / 3.0), $MachinePrecision] / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)
\left(1 + \frac{\frac{rand}{3}}{\sqrt{a + -0.3333333333333333}}\right) \cdot \left(a + -0.3333333333333333\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.1

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + -0.3333333333333333\right) \cdot 9}} \cdot rand\right)} \]
    Proof
    (*.f64 (+.f64 a -1/3) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 (+.f64 a -1/3) 9))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (+.f64 a (Rewrite<= metadata-eval (neg.f64 1/3))) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 (+.f64 a -1/3) 9))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (+.f64 a (neg.f64 (Rewrite<= metadata-eval (/.f64 1 3)))) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 (+.f64 a -1/3) 9))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (Rewrite<= sub-neg_binary64 (-.f64 a (/.f64 1 3))) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 (+.f64 a -1/3) 9))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 a (/.f64 1 3)) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 (+.f64 a (Rewrite<= metadata-eval (neg.f64 1/3))) 9))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 a (/.f64 1 3)) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 (+.f64 a (neg.f64 (Rewrite<= metadata-eval (/.f64 1 3)))) 9))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 a (/.f64 1 3)) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 (Rewrite<= sub-neg_binary64 (-.f64 a (/.f64 1 3))) 9))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 a (/.f64 1 3)) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (Rewrite<= *-commutative_binary64 (*.f64 9 (-.f64 a (/.f64 1 3)))))) rand))): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 a (/.f64 1 3)) (+.f64 1 (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 9 (-.f64 a (/.f64 1 3))))) rand)))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 a (/.f64 1 3)) (Rewrite<= sub-neg_binary64 (-.f64 1 (neg.f64 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 9 (-.f64 a (/.f64 1 3))))) rand))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 1 (-.f64 a (/.f64 1 3))) (*.f64 (neg.f64 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 9 (-.f64 a (/.f64 1 3))))) rand)) (-.f64 a (/.f64 1 3))))): 1 points increase in error, 5 points decrease in error
    (-.f64 (Rewrite=> *-lft-identity_binary64 (-.f64 a (/.f64 1 3))) (*.f64 (neg.f64 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 9 (-.f64 a (/.f64 1 3))))) rand)) (-.f64 a (/.f64 1 3)))): 0 points increase in error, 0 points decrease in error
    (Rewrite=> cancel-sign-sub_binary64 (+.f64 (-.f64 a (/.f64 1 3)) (*.f64 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 9 (-.f64 a (/.f64 1 3))))) rand) (-.f64 a (/.f64 1 3))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (-.f64 a (/.f64 1 3)))) (*.f64 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 9 (-.f64 a (/.f64 1 3))))) rand) (-.f64 a (/.f64 1 3)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt-in_binary64 (*.f64 (-.f64 a (/.f64 1 3)) (+.f64 1 (*.f64 (/.f64 1 (sqrt.f64 (*.f64 9 (-.f64 a (/.f64 1 3))))) rand)))): 5 points increase in error, 1 points decrease in error
  3. Applied egg-rr0.1

    \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{-rand}{\sqrt{a + -0.3333333333333333} \cdot -3}}\right) \]
  4. Simplified0.1

    \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{\frac{rand}{3}}{\sqrt{a + -0.3333333333333333}}}\right) \]
    Proof
    (/.f64 (/.f64 rand 3) (sqrt.f64 (+.f64 a -1/3))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-/r*_binary64 (/.f64 rand (*.f64 3 (sqrt.f64 (+.f64 a -1/3))))): 38 points increase in error, 37 points decrease in error
    (/.f64 rand (*.f64 (Rewrite<= metadata-eval (/.f64 1 1/3)) (sqrt.f64 (+.f64 a -1/3)))): 0 points increase in error, 0 points decrease in error
    (/.f64 rand (Rewrite<= associate-/r/_binary64 (/.f64 1 (/.f64 1/3 (sqrt.f64 (+.f64 a -1/3)))))): 56 points increase in error, 23 points decrease in error
    (/.f64 rand (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 1 (sqrt.f64 (+.f64 a -1/3))) 1/3))): 21 points increase in error, 31 points decrease in error
    (/.f64 rand (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (sqrt.f64 (+.f64 a -1/3)) 1)) 1/3)): 0 points increase in error, 0 points decrease in error
    (/.f64 rand (/.f64 (Rewrite=> *-rgt-identity_binary64 (sqrt.f64 (+.f64 a -1/3))) 1/3)): 0 points increase in error, 0 points decrease in error
    (Rewrite=> associate-/r/_binary64 (*.f64 (/.f64 rand (sqrt.f64 (+.f64 a -1/3))) 1/3)): 39 points increase in error, 40 points decrease in error
    (*.f64 (/.f64 rand (sqrt.f64 (+.f64 a -1/3))) (Rewrite<= metadata-eval (/.f64 -1 -3))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= times-frac_binary64 (/.f64 (*.f64 rand -1) (*.f64 (sqrt.f64 (+.f64 a -1/3)) -3))): 32 points increase in error, 58 points decrease in error
    (/.f64 (Rewrite=> *-commutative_binary64 (*.f64 -1 rand)) (*.f64 (sqrt.f64 (+.f64 a -1/3)) -3)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 rand)) (*.f64 (sqrt.f64 (+.f64 a -1/3)) -3)): 0 points increase in error, 0 points decrease in error
  5. Final simplification0.1

    \[\leadsto \left(1 + \frac{\frac{rand}{3}}{\sqrt{a + -0.3333333333333333}}\right) \cdot \left(a + -0.3333333333333333\right) \]

Alternatives

Alternative 1
Error1.5
Cost7236
\[\begin{array}{l} \mathbf{if}\;a \leq 92000:\\ \;\;\;\;0.3333333333333333 \cdot \frac{rand \cdot \left(a + -0.3333333333333333\right)}{\sqrt{a + -0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(1 + \frac{\frac{rand}{3}}{\sqrt{a}}\right)\\ \end{array} \]
Alternative 2
Error0.2
Cost7232
\[\left(1 + rand \cdot \frac{0.3333333333333333}{\sqrt{a + -0.3333333333333333}}\right) \cdot \left(a + -0.3333333333333333\right) \]
Alternative 3
Error0.1
Cost7232
\[\left(1 + \frac{rand}{\sqrt{-3 + a \cdot 9}}\right) \cdot \left(a + -0.3333333333333333\right) \]
Alternative 4
Error0.2
Cost7232
\[\left(1 + \frac{rand \cdot 0.3333333333333333}{\sqrt{a + -0.3333333333333333}}\right) \cdot \left(a + -0.3333333333333333\right) \]
Alternative 5
Error5.7
Cost7112
\[\begin{array}{l} t_0 := rand \cdot \left(0.3333333333333333 \cdot \sqrt{a + -0.3333333333333333}\right)\\ \mathbf{if}\;rand \leq -1.25 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq 1.55 \cdot 10^{+90}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error5.6
Cost7112
\[\begin{array}{l} t_0 := \left(rand \cdot 0.3333333333333333\right) \cdot \sqrt{a + -0.3333333333333333}\\ \mathbf{if}\;rand \leq -2.65 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq 5 \cdot 10^{+90}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error5.7
Cost7112
\[\begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\\ \mathbf{if}\;rand \leq -1.55 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq 5.5 \cdot 10^{+91}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error1.5
Cost7108
\[\begin{array}{l} \mathbf{if}\;a \leq 100000:\\ \;\;\;\;\left(rand \cdot 0.3333333333333333\right) \cdot \sqrt{a + -0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)\\ \end{array} \]
Alternative 9
Error1.5
Cost7108
\[\begin{array}{l} \mathbf{if}\;a \leq 112000:\\ \;\;\;\;\left(rand \cdot 0.3333333333333333\right) \cdot \sqrt{a + -0.3333333333333333}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(1 + \frac{\frac{rand}{3}}{\sqrt{a}}\right)\\ \end{array} \]
Alternative 10
Error0.9
Cost7104
\[\left(1 + \frac{\frac{rand}{3}}{\sqrt{a}}\right) \cdot \left(a + -0.3333333333333333\right) \]
Alternative 11
Error6.2
Cost6984
\[\begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \mathbf{if}\;rand \leq -3.6 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq 1.55 \cdot 10^{+90}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error18.4
Cost192
\[a + -0.3333333333333333 \]
Alternative 13
Error63.0
Cost64
\[-0.3333333333333333 \]
Alternative 14
Error19.2
Cost64
\[a \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (a rand)
  :name "Octave 3.8, oct_fill_randg"
  :precision binary64
  (* (- a (/ 1.0 3.0)) (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 (- a (/ 1.0 3.0))))) rand))))