?

Average Accuracy: 99.4% → 99.4%
Time: 18.1s
Precision: binary32
Cost: 13216

?

\[\left(10^{-5} \leq u \land u \leq 1\right) \land \left(0 \leq v \land v \leq 109.746574\right)\]
\[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
\[1 + v \cdot \left(2 \cdot \log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right)\right) \]
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (* 2.0 (log (sqrt (fma (- 1.0 u) (exp (/ -2.0 v)) u)))))))
float code(float u, float v) {
	return 1.0f + (v * logf((u + ((1.0f - u) * expf((-2.0f / v))))));
}
float code(float u, float v) {
	return 1.0f + (v * (2.0f * logf(sqrtf(fmaf((1.0f - u), expf((-2.0f / v)), u)))));
}
function code(u, v)
	return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))))
end
function code(u, v)
	return Float32(Float32(1.0) + Float32(v * Float32(Float32(2.0) * log(sqrt(fma(Float32(Float32(1.0) - u), exp(Float32(Float32(-2.0) / v)), u))))))
end
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
1 + v \cdot \left(2 \cdot \log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right)\right)

Error?

Derivation?

  1. Initial program 99.4%

    \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
  2. Applied egg-rr99.4%

    \[\leadsto 1 + v \cdot \color{blue}{\left(\log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right) + \log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right)\right)} \]
    Proof

    [Start]99.4

    \[ 1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]

    add-sqr-sqrt [=>]99.3

    \[ 1 + v \cdot \log \color{blue}{\left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}} \cdot \sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right)} \]

    log-prod [=>]99.4

    \[ 1 + v \cdot \color{blue}{\left(\log \left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right) + \log \left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right)\right)} \]

    +-commutative [=>]99.4

    \[ 1 + v \cdot \left(\log \left(\sqrt{\color{blue}{\left(1 - u\right) \cdot e^{\frac{-2}{v}} + u}}\right) + \log \left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right)\right) \]

    fma-def [=>]99.4

    \[ 1 + v \cdot \left(\log \left(\sqrt{\color{blue}{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}}\right) + \log \left(\sqrt{u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}}\right)\right) \]

    +-commutative [=>]99.4

    \[ 1 + v \cdot \left(\log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right) + \log \left(\sqrt{\color{blue}{\left(1 - u\right) \cdot e^{\frac{-2}{v}} + u}}\right)\right) \]

    fma-def [=>]99.4

    \[ 1 + v \cdot \left(\log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right) + \log \left(\sqrt{\color{blue}{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}}\right)\right) \]
  3. Simplified99.4%

    \[\leadsto 1 + v \cdot \color{blue}{\left(2 \cdot \log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right)\right)} \]
    Proof

    [Start]99.4

    \[ 1 + v \cdot \left(\log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right) + \log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right)\right) \]

    count-2 [=>]99.4

    \[ 1 + v \cdot \color{blue}{\left(2 \cdot \log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right)\right)} \]
  4. Final simplification99.4%

    \[\leadsto 1 + v \cdot \left(2 \cdot \log \left(\sqrt{\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)}\right)\right) \]

Alternatives

Alternative 1
Accuracy99.4%
Cost9952
\[1 + v \cdot \log \left(\mathsf{fma}\left(1 - u, e^{\frac{-2}{v}}, u\right)\right) \]
Alternative 2
Accuracy99.4%
Cost6816
\[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
Alternative 3
Accuracy95.8%
Cost6688
\[1 + v \cdot \log \left(u + e^{\frac{-2}{v}}\right) \]
Alternative 4
Accuracy94.2%
Cost3360
\[1 + v \cdot \log u \]
Alternative 5
Accuracy90.9%
Cost932
\[\begin{array}{l} \mathbf{if}\;v \leq 0.15000000596046448:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(2 \cdot u + \frac{u}{v \cdot v} \cdot \left(1.3333333333333333 + u \cdot -4\right)\right) - \frac{u \cdot \left(-2 + 2 \cdot u\right)}{v}\right) + -1\\ \end{array} \]
Alternative 6
Accuracy90.4%
Cost548
\[\begin{array}{l} \mathbf{if}\;v \leq 0.15000000596046448:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + v \cdot \left(u \cdot \frac{1 + v}{v \cdot \left(v \cdot 0.5\right)}\right)\\ \end{array} \]
Alternative 7
Accuracy90.5%
Cost548
\[\begin{array}{l} \mathbf{if}\;v \leq 0.15000000596046448:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(2 \cdot u - \frac{u \cdot \left(-2 + 2 \cdot u\right)}{v}\right)\\ \end{array} \]
Alternative 8
Accuracy90.4%
Cost516
\[\begin{array}{l} \mathbf{if}\;v \leq 0.15000000596046448:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + v \cdot \left(u \cdot \frac{-2 - \frac{2}{v}}{-v}\right)\\ \end{array} \]
Alternative 9
Accuracy90.4%
Cost484
\[\begin{array}{l} \mathbf{if}\;v \leq 0.15000000596046448:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + v \cdot \left(\frac{u}{v} \cdot \left(2 + \frac{2}{v}\right)\right)\\ \end{array} \]
Alternative 10
Accuracy90.4%
Cost356
\[\begin{array}{l} \mathbf{if}\;v \leq 0.15000000596046448:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + 2 \cdot \left(u + \frac{u}{v}\right)\\ \end{array} \]
Alternative 11
Accuracy5.9%
Cost32
\[-1 \]
Alternative 12
Accuracy86.5%
Cost32
\[1 \]

Error

Reproduce?

herbie shell --seed 2023153 
(FPCore (u v)
  :name "HairBSDF, sample_f, cosTheta"
  :precision binary32
  :pre (and (and (<= 1e-5 u) (<= u 1.0)) (and (<= 0.0 v) (<= v 109.746574)))
  (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))