?

Average Error: 0.1 → 0.1
Time: 11.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 + \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111} \cdot rand\right) + -0.3333333333333333 \]
(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 (* (sqrt (+ -0.037037037037037035 (* a 0.1111111111111111))) rand))
  -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 (a + (sqrt((-0.037037037037037035 + (a * 0.1111111111111111))) * rand)) + -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 = (a + (sqrt(((-0.037037037037037035d0) + (a * 0.1111111111111111d0))) * rand)) + (-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 (a + (Math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111))) * rand)) + -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 (a + (math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111))) * rand)) + -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(a + Float64(sqrt(Float64(-0.037037037037037035 + Float64(a * 0.1111111111111111))) * rand)) + -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 = (a + (sqrt((-0.037037037037037035 + (a * 0.1111111111111111))) * rand)) + -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[(a + N[(N[Sqrt[N[(-0.037037037037037035 + N[(a * 0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision] + -0.3333333333333333), $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 + \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111} \cdot rand\right) + -0.3333333333333333

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

    [Start]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) \]

    cancel-sign-sub [<=]0.1

    \[ \left(a - \frac{1}{3}\right) \cdot \color{blue}{\left(1 - \left(-\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}\right) \cdot rand\right)} \]

    distribute-lft-neg-in [<=]0.1

    \[ \left(a - \frac{1}{3}\right) \cdot \left(1 - \color{blue}{\left(-\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)}\right) \]

    sub-neg [=>]0.1

    \[ \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 - \left(-\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right) \]

    metadata-eval [=>]0.1

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

    metadata-eval [=>]0.1

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

    sub-neg [=>]0.1

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

    remove-double-neg [=>]0.1

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

    /-rgt-identity [<=]0.1

    \[ \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\color{blue}{\frac{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}{1}}} \cdot rand\right) \]
  3. Taylor expanded in rand around 0 0.2

    \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot \left(\sqrt{a - 0.3333333333333333} \cdot rand\right) + a\right) - 0.3333333333333333} \]
  4. Applied egg-rr20.5

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

    \[\leadsto \left(\color{blue}{\sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111} \cdot rand} + a\right) - 0.3333333333333333 \]
  6. Final simplification0.1

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

Alternatives

Alternative 1
Error0.9
Cost7240
\[\begin{array}{l} \mathbf{if}\;rand \leq -7200000000:\\ \;\;\;\;a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \mathbf{elif}\;rand \leq 5.5 \cdot 10^{-14}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)\\ \end{array} \]
Alternative 2
Error6.2
Cost7113
\[\begin{array}{l} \mathbf{if}\;rand \leq -3.2 \cdot 10^{+127} \lor \neg \left(rand \leq 3 \cdot 10^{+74}\right):\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\\ \mathbf{else}:\\ \;\;\;\;a + -0.3333333333333333\\ \end{array} \]
Alternative 3
Error0.9
Cost7113
\[\begin{array}{l} \mathbf{if}\;rand \leq -7200000000 \lor \neg \left(rand \leq 5 \cdot 10^{-14}\right):\\ \;\;\;\;a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \mathbf{else}:\\ \;\;\;\;a + -0.3333333333333333\\ \end{array} \]
Alternative 4
Error6.1
Cost7112
\[\begin{array}{l} \mathbf{if}\;rand \leq -3.2 \cdot 10^{+127}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\\ \mathbf{elif}\;rand \leq 1.75 \cdot 10^{+74}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111} \cdot rand\\ \end{array} \]
Alternative 5
Error6.1
Cost7112
\[\begin{array}{l} \mathbf{if}\;rand \leq -3.2 \cdot 10^{+127}:\\ \;\;\;\;rand \cdot \left(0.3333333333333333 \cdot \sqrt{a + -0.3333333333333333}\right)\\ \mathbf{elif}\;rand \leq 5.2 \cdot 10^{+74}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111} \cdot rand\\ \end{array} \]
Alternative 6
Error0.9
Cost7104
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{0.3333333333333333}{\frac{\sqrt{a}}{rand}}\right) \]
Alternative 7
Error0.8
Cost7104
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right) \]
Alternative 8
Error0.2
Cost7104
\[\left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) + -0.3333333333333333 \]
Alternative 9
Error6.6
Cost7048
\[\begin{array}{l} \mathbf{if}\;rand \leq -3.2 \cdot 10^{+127}:\\ \;\;\;\;rand \cdot \left(0.3333333333333333 \cdot \sqrt{a}\right)\\ \mathbf{elif}\;rand \leq 1.85 \cdot 10^{+75}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{rand}{\frac{{a}^{-0.5}}{0.3333333333333333}}\\ \end{array} \]
Alternative 10
Error6.6
Cost6985
\[\begin{array}{l} \mathbf{if}\;rand \leq -3.2 \cdot 10^{+127} \lor \neg \left(rand \leq 4.4 \cdot 10^{+75}\right):\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \mathbf{else}:\\ \;\;\;\;a + -0.3333333333333333\\ \end{array} \]
Alternative 11
Error6.6
Cost6984
\[\begin{array}{l} \mathbf{if}\;rand \leq -3.2 \cdot 10^{+127}:\\ \;\;\;\;rand \cdot \left(0.3333333333333333 \cdot \sqrt{a}\right)\\ \mathbf{elif}\;rand \leq 3.25 \cdot 10^{+75}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \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 2023045 
(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))))