Average Error: 0.1 → 0.1
Time: 19.1s
Precision: binary32
Cost: 22816
\[\left(\left(\left(\left(-1 \leq cosTheta_i \land cosTheta_i \leq 1\right) \land \left(-1 \leq cosTheta_O \land cosTheta_O \leq 1\right)\right) \land \left(-1 \leq sinTheta_i \land sinTheta_i \leq 1\right)\right) \land \left(-1 \leq sinTheta_O \land sinTheta_O \leq 1\right)\right) \land \left(-1.5707964 \leq v \land v \leq 0.1\right)\]
\[e^{\left(\left(\left(\frac{cosTheta_i \cdot cosTheta_O}{v} - \frac{sinTheta_i \cdot sinTheta_O}{v}\right) - \frac{1}{v}\right) + 0.6931\right) + \log \left(\frac{1}{2 \cdot v}\right)} \]
\[\left(e^{0.6931} \cdot \frac{0.5}{v}\right) \cdot {\left({\left(e^{\mathsf{fma}\left(cosTheta_i, cosTheta_O, -1\right)}\right)}^{\left({v}^{-0.5}\right)}\right)}^{\left({v}^{-0.5}\right)} \]
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (exp
  (+
   (+
    (-
     (- (/ (* cosTheta_i cosTheta_O) v) (/ (* sinTheta_i sinTheta_O) v))
     (/ 1.0 v))
    0.6931)
   (log (/ 1.0 (* 2.0 v))))))
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
 :precision binary32
 (*
  (* (exp 0.6931) (/ 0.5 v))
  (pow
   (pow (exp (fma cosTheta_i cosTheta_O -1.0)) (pow v -0.5))
   (pow v -0.5))))
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return expf(((((((cosTheta_i * cosTheta_O) / v) - ((sinTheta_i * sinTheta_O) / v)) - (1.0f / v)) + 0.6931f) + logf((1.0f / (2.0f * v)))));
}
float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
	return (expf(0.6931f) * (0.5f / v)) * powf(powf(expf(fmaf(cosTheta_i, cosTheta_O, -1.0f)), powf(v, -0.5f)), powf(v, -0.5f));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return exp(Float32(Float32(Float32(Float32(Float32(Float32(cosTheta_i * cosTheta_O) / v) - Float32(Float32(sinTheta_i * sinTheta_O) / v)) - Float32(Float32(1.0) / v)) + Float32(0.6931)) + log(Float32(Float32(1.0) / Float32(Float32(2.0) * v)))))
end
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v)
	return Float32(Float32(exp(Float32(0.6931)) * Float32(Float32(0.5) / v)) * ((exp(fma(cosTheta_i, cosTheta_O, Float32(-1.0))) ^ (v ^ Float32(-0.5))) ^ (v ^ Float32(-0.5))))
end
e^{\left(\left(\left(\frac{cosTheta_i \cdot cosTheta_O}{v} - \frac{sinTheta_i \cdot sinTheta_O}{v}\right) - \frac{1}{v}\right) + 0.6931\right) + \log \left(\frac{1}{2 \cdot v}\right)}
\left(e^{0.6931} \cdot \frac{0.5}{v}\right) \cdot {\left({\left(e^{\mathsf{fma}\left(cosTheta_i, cosTheta_O, -1\right)}\right)}^{\left({v}^{-0.5}\right)}\right)}^{\left({v}^{-0.5}\right)}

Error

Derivation

  1. Initial program 0.1

    \[e^{\left(\left(\left(\frac{cosTheta_i \cdot cosTheta_O}{v} - \frac{sinTheta_i \cdot sinTheta_O}{v}\right) - \frac{1}{v}\right) + 0.6931\right) + \log \left(\frac{1}{2 \cdot v}\right)} \]
  2. Taylor expanded in sinTheta_i around 0 0.1

    \[\leadsto \color{blue}{e^{\left(0.6931 + \left(\log \left(\frac{0.5}{v}\right) + \frac{cosTheta_i \cdot cosTheta_O}{v}\right)\right) - \frac{1}{v}}} \]
  3. Simplified0.1

    \[\leadsto \color{blue}{\left(e^{0.6931} \cdot \frac{0.5}{v}\right) \cdot e^{\frac{\mathsf{fma}\left(cosTheta_i, cosTheta_O, -1\right)}{v}}} \]
    Proof
    (*.f32 (*.f32 (exp.f32 6931/10000) (/.f32 1/2 v)) (exp.f32 (/.f32 (fma.f32 cosTheta_i cosTheta_O -1) v))): 0 points increase in error, 0 points decrease in error
    (*.f32 (*.f32 (exp.f32 6931/10000) (Rewrite<= rem-exp-log_binary32 (exp.f32 (log.f32 (/.f32 1/2 v))))) (exp.f32 (/.f32 (fma.f32 cosTheta_i cosTheta_O -1) v))): 3 points increase in error, 0 points decrease in error
    (*.f32 (Rewrite<= exp-sum_binary32 (exp.f32 (+.f32 6931/10000 (log.f32 (/.f32 1/2 v))))) (exp.f32 (/.f32 (fma.f32 cosTheta_i cosTheta_O -1) v))): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 6931/10000 (log.f32 (/.f32 1/2 v)))) (exp.f32 (/.f32 (fma.f32 cosTheta_i cosTheta_O (Rewrite<= metadata-eval (neg.f32 1))) v))): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 6931/10000 (log.f32 (/.f32 1/2 v)))) (exp.f32 (/.f32 (Rewrite<= fma-neg_binary32 (-.f32 (*.f32 cosTheta_i cosTheta_O) 1)) v))): 0 points increase in error, 0 points decrease in error
    (*.f32 (exp.f32 (+.f32 6931/10000 (log.f32 (/.f32 1/2 v)))) (exp.f32 (Rewrite=> div-sub_binary32 (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 1 v))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= exp-sum_binary32 (exp.f32 (+.f32 (+.f32 6931/10000 (log.f32 (/.f32 1/2 v))) (-.f32 (/.f32 (*.f32 cosTheta_i cosTheta_O) v) (/.f32 1 v))))): 3 points increase in error, 1 points decrease in error
    (exp.f32 (Rewrite<= associate--l+_binary32 (-.f32 (+.f32 (+.f32 6931/10000 (log.f32 (/.f32 1/2 v))) (/.f32 (*.f32 cosTheta_i cosTheta_O) v)) (/.f32 1 v)))): 0 points increase in error, 0 points decrease in error
    (exp.f32 (-.f32 (Rewrite<= associate-+r+_binary32 (+.f32 6931/10000 (+.f32 (log.f32 (/.f32 1/2 v)) (/.f32 (*.f32 cosTheta_i cosTheta_O) v)))) (/.f32 1 v))): 0 points increase in error, 0 points decrease in error
  4. Applied egg-rr0.1

    \[\leadsto \left(e^{0.6931} \cdot \frac{0.5}{v}\right) \cdot \color{blue}{{\left({\left(e^{\mathsf{fma}\left(cosTheta_i, cosTheta_O, -1\right)}\right)}^{\left(\sqrt{\frac{1}{v}}\right)}\right)}^{\left(\sqrt{\frac{1}{v}}\right)}} \]
  5. Applied egg-rr0.1

    \[\leadsto \left(e^{0.6931} \cdot \frac{0.5}{v}\right) \cdot {\left({\left(e^{\mathsf{fma}\left(cosTheta_i, cosTheta_O, -1\right)}\right)}^{\color{blue}{\left({v}^{-0.5}\right)}}\right)}^{\left(\sqrt{\frac{1}{v}}\right)} \]
  6. Applied egg-rr0.1

    \[\leadsto \left(e^{0.6931} \cdot \frac{0.5}{v}\right) \cdot {\left({\left(e^{\mathsf{fma}\left(cosTheta_i, cosTheta_O, -1\right)}\right)}^{\left({v}^{-0.5}\right)}\right)}^{\color{blue}{\left({v}^{-0.5}\right)}} \]
  7. Final simplification0.1

    \[\leadsto \left(e^{0.6931} \cdot \frac{0.5}{v}\right) \cdot {\left({\left(e^{\mathsf{fma}\left(cosTheta_i, cosTheta_O, -1\right)}\right)}^{\left({v}^{-0.5}\right)}\right)}^{\left({v}^{-0.5}\right)} \]

Alternatives

Alternative 1
Error0.1
Cost10048
\[{\left(\sqrt{\frac{0.5}{v} \cdot e^{0.6931 + \frac{-1 + cosTheta_i \cdot cosTheta_O}{v}}}\right)}^{2} \]
Alternative 2
Error0.1
Cost3488
\[\frac{0.5}{v} \cdot e^{0.6931 + \frac{-1}{v}} \]
Alternative 3
Error0.6
Cost3424
\[e^{\frac{-1 + cosTheta_i \cdot cosTheta_O}{v}} \]
Alternative 4
Error9.5
Cost288
\[-1 + \left(1 + cosTheta_i \cdot \frac{cosTheta_O}{v}\right) \]
Alternative 5
Error19.6
Cost224
\[\frac{1}{\frac{v}{cosTheta_i \cdot cosTheta_O}} \]
Alternative 6
Error25.6
Cost160
\[\frac{cosTheta_i}{\frac{v}{cosTheta_O}} \]
Alternative 7
Error19.7
Cost160
\[\frac{cosTheta_i \cdot cosTheta_O}{v} \]
Alternative 8
Error29.9
Cost32
\[1 \]

Error

Reproduce

herbie shell --seed 2022295 
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
  :name "HairBSDF, Mp, lower"
  :precision binary32
  :pre (and (and (and (and (and (<= -1.0 cosTheta_i) (<= cosTheta_i 1.0)) (and (<= -1.0 cosTheta_O) (<= cosTheta_O 1.0))) (and (<= -1.0 sinTheta_i) (<= sinTheta_i 1.0))) (and (<= -1.0 sinTheta_O) (<= sinTheta_O 1.0))) (and (<= -1.5707964 v) (<= v 0.1)))
  (exp (+ (+ (- (- (/ (* cosTheta_i cosTheta_O) v) (/ (* sinTheta_i sinTheta_O) v)) (/ 1.0 v)) 0.6931) (log (/ 1.0 (* 2.0 v))))))