Average Error: 0.1 → 0.1
Time: 12.5s
Precision: binary64
Cost: 7104
\[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
\[\left(a + -0.3333333333333333\right) + \sqrt{a \cdot 0.1111111111111111 + -0.037037037037037035} \cdot rand \]
(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
 (+
  (+ a -0.3333333333333333)
  (* (sqrt (+ (* a 0.1111111111111111) -0.037037037037037035)) rand)))
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 (a + -0.3333333333333333) + (sqrt(((a * 0.1111111111111111) + -0.037037037037037035)) * rand);
}
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 = (a + (-0.3333333333333333d0)) + (sqrt(((a * 0.1111111111111111d0) + (-0.037037037037037035d0))) * rand)
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 (a + -0.3333333333333333) + (Math.sqrt(((a * 0.1111111111111111) + -0.037037037037037035)) * rand);
}
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 (a + -0.3333333333333333) + (math.sqrt(((a * 0.1111111111111111) + -0.037037037037037035)) * rand)
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(a + -0.3333333333333333) + Float64(sqrt(Float64(Float64(a * 0.1111111111111111) + -0.037037037037037035)) * rand))
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 = (a + -0.3333333333333333) + (sqrt(((a * 0.1111111111111111) + -0.037037037037037035)) * rand);
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[(a + -0.3333333333333333), $MachinePrecision] + N[(N[Sqrt[N[(N[(a * 0.1111111111111111), $MachinePrecision] + -0.037037037037037035), $MachinePrecision]], $MachinePrecision] * rand), $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(a + -0.3333333333333333\right) + \sqrt{a \cdot 0.1111111111111111 + -0.037037037037037035} \cdot rand

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))))): 2 points increase in error, 4 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)))): 4 points increase in error, 2 points decrease in error
  3. Applied egg-rr0.2

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

    \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{0.3333333333333333}{\sqrt{a + -0.3333333333333333}}} \cdot rand\right) \]
    Proof
    (/.f64 1/3 (sqrt.f64 (+.f64 a -1/3))): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= metadata-eval (*.f64 1 1/3)) (sqrt.f64 (+.f64 a -1/3))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1 (sqrt.f64 (+.f64 a -1/3))) 1/3)): 33 points increase in error, 46 points decrease in error
    (*.f64 (Rewrite<= unpow-1_binary64 (pow.f64 (sqrt.f64 (+.f64 a -1/3)) -1)) 1/3): 0 points increase in error, 0 points decrease in error
  5. Applied egg-rr9.1

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

    \[\leadsto \color{blue}{\left(a + -0.3333333333333333\right) + \frac{0.3333333333333333 \cdot rand}{\frac{\sqrt{a + -0.3333333333333333}}{a + -0.3333333333333333}}} \]
    Proof
    (+.f64 (+.f64 a -1/3) (/.f64 (*.f64 1/3 rand) (/.f64 (sqrt.f64 (+.f64 a -1/3)) (+.f64 a -1/3)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 a -1/3) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (*.f64 1/3 rand) (+.f64 a -1/3)) (sqrt.f64 (+.f64 a -1/3))))): 47 points increase in error, 15 points decrease in error
    (Rewrite=> associate-+l+_binary64 (+.f64 a (+.f64 -1/3 (/.f64 (*.f64 (*.f64 1/3 rand) (+.f64 a -1/3)) (sqrt.f64 (+.f64 a -1/3)))))): 0 points increase in error, 0 points decrease in error
  7. Applied egg-rr0.1

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

    \[\leadsto \left(a + -0.3333333333333333\right) + \color{blue}{{\left(0.1111111111111111 \cdot \left(a + -0.3333333333333333\right)\right)}^{0.5}} \cdot rand \]
  9. Simplified0.1

    \[\leadsto \left(a + -0.3333333333333333\right) + \color{blue}{\sqrt{a \cdot 0.1111111111111111 + -0.037037037037037035}} \cdot rand \]
    Proof
    (sqrt.f64 (+.f64 (*.f64 a 1/9) -1/27)): 0 points increase in error, 0 points decrease in error
    (sqrt.f64 (+.f64 (*.f64 a 1/9) (Rewrite<= metadata-eval (*.f64 -1/3 1/9)))): 0 points increase in error, 0 points decrease in error
    (sqrt.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 1/9 (+.f64 a -1/3)))): 2 points increase in error, 1 points decrease in error
    (Rewrite<= unpow1/2_binary64 (pow.f64 (*.f64 1/9 (+.f64 a -1/3)) 1/2)): 0 points increase in error, 0 points decrease in error
  10. Final simplification0.1

    \[\leadsto \left(a + -0.3333333333333333\right) + \sqrt{a \cdot 0.1111111111111111 + -0.037037037037037035} \cdot rand \]

Alternatives

Alternative 1
Error0.2
Cost7104
\[\left(a + -0.3333333333333333\right) + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right) \]

Error

Reproduce

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