Average Error: 0.2 → 0.1
Time: 9.5s
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{-0.3333333333333333 + a}}\right) \cdot \left(-0.3333333333333333 + a\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 (+ -0.3333333333333333 a))))
  (+ -0.3333333333333333 a)))
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((-0.3333333333333333 + a)))) * (-0.3333333333333333 + a);
}
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(((-0.3333333333333333d0) + a)))) * ((-0.3333333333333333d0) + a)
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((-0.3333333333333333 + a)))) * (-0.3333333333333333 + a);
}
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((-0.3333333333333333 + a)))) * (-0.3333333333333333 + a)
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(-0.3333333333333333 + a)))) * Float64(-0.3333333333333333 + a))
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((-0.3333333333333333 + a)))) * (-0.3333333333333333 + a);
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[(-0.3333333333333333 + a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 + a), $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{-0.3333333333333333 + a}}\right) \cdot \left(-0.3333333333333333 + a\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.2

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

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

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

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

Alternatives

Alternative 1
Error1.0
Cost7240
\[\begin{array}{l} t_0 := a \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)\\ \mathbf{if}\;rand \leq -2.4862622485972186 \cdot 10^{+22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq 8.222666501894201 \cdot 10^{-7}:\\ \;\;\;\;-0.3333333333333333 + a\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error5.9
Cost7112
\[\begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{-0.3333333333333333 + a}\right)\\ \mathbf{if}\;rand \leq -1.6366252543701598 \cdot 10^{+107}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq 2.6718955914379515 \cdot 10^{+62}:\\ \;\;\;\;-0.3333333333333333 + a\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error5.9
Cost7112
\[\begin{array}{l} \mathbf{if}\;rand \leq -1.6366252543701598 \cdot 10^{+107}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{-0.3333333333333333 + a}\right)\\ \mathbf{elif}\;rand \leq 2.6718955914379515 \cdot 10^{+62}:\\ \;\;\;\;-0.3333333333333333 + a\\ \mathbf{else}:\\ \;\;\;\;rand \cdot \sqrt{\left(-0.3333333333333333 + a\right) \cdot 0.1111111111111111}\\ \end{array} \]
Alternative 4
Error0.2
Cost7104
\[-0.3333333333333333 + \left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{-0.3333333333333333 + a}\right)\right) \]
Alternative 5
Error6.4
Cost6984
\[\begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \mathbf{if}\;rand \leq -1.6366252543701598 \cdot 10^{+107}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq 2.6718955914379515 \cdot 10^{+62}:\\ \;\;\;\;-0.3333333333333333 + a\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error6.4
Cost6984
\[\begin{array}{l} \mathbf{if}\;rand \leq -1.6366252543701598 \cdot 10^{+107}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \mathbf{elif}\;rand \leq 2.6718955914379515 \cdot 10^{+62}:\\ \;\;\;\;-0.3333333333333333 + a\\ \mathbf{else}:\\ \;\;\;\;rand \cdot \left(0.3333333333333333 \cdot \sqrt{a}\right)\\ \end{array} \]
Alternative 7
Error0.9
Cost6976
\[-0.3333333333333333 + \left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\right) \]
Alternative 8
Error18.8
Cost192
\[-0.3333333333333333 + a \]
Alternative 9
Error63.1
Cost64
\[-0.3333333333333333 \]
Alternative 10
Error19.5
Cost64
\[a \]

Error

Reproduce

herbie shell --seed 2022296 
(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))))