
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/
(*
(exp (- (/ (* sinTheta_i sinTheta_O) v)))
(/ (* cosTheta_i cosTheta_O) v))
(* (* (sinh (/ 1.0 v)) 2.0) v)))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/
(*
(exp (- (/ (* sinTheta_i sinTheta_O) v)))
(/ (* cosTheta_i cosTheta_O) v))
(* (* (sinh (/ 1.0 v)) 2.0) v)))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (exp(-((sintheta_i * sintheta_o) / v)) * ((costheta_i * costheta_o) / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(Float32(cosTheta_i * cosTheta_O) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * ((cosTheta_i * cosTheta_O) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \frac{cosTheta\_i \cdot cosTheta\_O}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/
(*
(exp (- (/ (* sinTheta_i sinTheta_O) v)))
(* cosTheta_O (* cosTheta_i (/ 1.0 v))))
(* (* (sinh (/ 1.0 v)) 2.0) v)))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf(-((sinTheta_i * sinTheta_O) / v)) * (cosTheta_O * (cosTheta_i * (1.0f / v)))) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (exp(-((sintheta_i * sintheta_o) / v)) * (costheta_o * (costheta_i * (1.0e0 / v)))) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(-Float32(Float32(sinTheta_i * sinTheta_O) / v))) * Float32(cosTheta_O * Float32(cosTheta_i * Float32(Float32(1.0) / v)))) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp(-((sinTheta_i * sinTheta_O) / v)) * (cosTheta_O * (cosTheta_i * (single(1.0) / v)))) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\frac{e^{-\frac{sinTheta\_i \cdot sinTheta\_O}{v}} \cdot \left(cosTheta\_O \cdot \left(cosTheta\_i \cdot \frac{1}{v}\right)\right)}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
Initial program 98.6%
Applied rewrites98.8%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(*
(*
(exp (* (- sinTheta_i) (/ sinTheta_O v)))
(fmin cosTheta_i cosTheta_O))
(/ (/ (fmax cosTheta_i cosTheta_O) v) (* (sinh (/ 1.0 v)) (+ v v)))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (expf((-sinTheta_i * (sinTheta_O / v))) * fminf(cosTheta_i, cosTheta_O)) * ((fmaxf(cosTheta_i, cosTheta_O) / v) / (sinhf((1.0f / v)) * (v + v)));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (exp((-sintheta_i * (sintheta_o / v))) * fmin(costheta_i, costheta_o)) * ((fmax(costheta_i, costheta_o) / v) / (sinh((1.0e0 / v)) * (v + v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(exp(Float32(Float32(-sinTheta_i) * Float32(sinTheta_O / v))) * fmin(cosTheta_i, cosTheta_O)) * Float32(Float32(fmax(cosTheta_i, cosTheta_O) / v) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(v + v)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (exp((-sinTheta_i * (sinTheta_O / v))) * min(cosTheta_i, cosTheta_O)) * ((max(cosTheta_i, cosTheta_O) / v) / (sinh((single(1.0) / v)) * (v + v))); end
\left(e^{\left(-sinTheta\_i\right) \cdot \frac{sinTheta\_O}{v}} \cdot \mathsf{min}\left(cosTheta\_i, cosTheta\_O\right)\right) \cdot \frac{\frac{\mathsf{max}\left(cosTheta\_i, cosTheta\_O\right)}{v}}{\sinh \left(\frac{1}{v}\right) \cdot \left(v + v\right)}
Initial program 98.6%
Applied rewrites98.6%
Applied rewrites98.6%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/
(* 1.0 (* cosTheta_O (* cosTheta_i (/ 1.0 v))))
(* (sinh (/ 1.0 v)) (+ v v))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (1.0f * (cosTheta_O * (cosTheta_i * (1.0f / v)))) / (sinhf((1.0f / v)) * (v + v));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (1.0e0 * (costheta_o * (costheta_i * (1.0e0 / v)))) / (sinh((1.0e0 / v)) * (v + v))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(1.0) * Float32(cosTheta_O * Float32(cosTheta_i * Float32(Float32(1.0) / v)))) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(v + v))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (single(1.0) * (cosTheta_O * (cosTheta_i * (single(1.0) / v)))) / (sinh((single(1.0) / v)) * (v + v)); end
\frac{1 \cdot \left(cosTheta\_O \cdot \left(cosTheta\_i \cdot \frac{1}{v}\right)\right)}{\sinh \left(\frac{1}{v}\right) \cdot \left(v + v\right)}
Initial program 98.6%
Applied rewrites98.8%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.5%
Applied rewrites98.5%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/
(* (* cosTheta_i cosTheta_O) (/ 1.0 v))
(* (* (sinh (/ 1.0 v)) 2.0) v)))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return ((cosTheta_i * cosTheta_O) * (1.0f / v)) / ((sinhf((1.0f / v)) * 2.0f) * v);
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = ((costheta_i * costheta_o) * (1.0e0 / v)) / ((sinh((1.0e0 / v)) * 2.0e0) * v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(cosTheta_i * cosTheta_O) * Float32(Float32(1.0) / v)) / Float32(Float32(sinh(Float32(Float32(1.0) / v)) * Float32(2.0)) * v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = ((cosTheta_i * cosTheta_O) * (single(1.0) / v)) / ((sinh((single(1.0) / v)) * single(2.0)) * v); end
\frac{\left(cosTheta\_i \cdot cosTheta\_O\right) \cdot \frac{1}{v}}{\left(\sinh \left(\frac{1}{v}\right) \cdot 2\right) \cdot v}
Initial program 98.6%
Applied rewrites98.7%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.5%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(*
(fmin cosTheta_i cosTheta_O)
(/ (/ (fmax cosTheta_i cosTheta_O) v) (* (sinh (/ 1.0 v)) (+ v v)))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return fminf(cosTheta_i, cosTheta_O) * ((fmaxf(cosTheta_i, cosTheta_O) / v) / (sinhf((1.0f / v)) * (v + v)));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = fmin(costheta_i, costheta_o) * ((fmax(costheta_i, costheta_o) / v) / (sinh((1.0e0 / v)) * (v + v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(fmin(cosTheta_i, cosTheta_O) * Float32(Float32(fmax(cosTheta_i, cosTheta_O) / v) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(v + v)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = min(cosTheta_i, cosTheta_O) * ((max(cosTheta_i, cosTheta_O) / v) / (sinh((single(1.0) / v)) * (v + v))); end
\mathsf{min}\left(cosTheta\_i, cosTheta\_O\right) \cdot \frac{\frac{\mathsf{max}\left(cosTheta\_i, cosTheta\_O\right)}{v}}{\sinh \left(\frac{1}{v}\right) \cdot \left(v + v\right)}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
Applied rewrites98.3%
Applied rewrites98.4%
Applied rewrites98.4%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(* cosTheta_O (/ (/ cosTheta_i v) (* (sinh (/ 1.0 v)) (+ v v)))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_O * ((cosTheta_i / v) / (sinhf((1.0f / v)) * (v + v)));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_o * ((costheta_i / v) / (sinh((1.0e0 / v)) * (v + v)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_O * Float32(Float32(cosTheta_i / v) / Float32(sinh(Float32(Float32(1.0) / v)) * Float32(v + v)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = cosTheta_O * ((cosTheta_i / v) / (sinh((single(1.0) / v)) * (v + v))); end
cosTheta\_O \cdot \frac{\frac{cosTheta\_i}{v}}{\sinh \left(\frac{1}{v}\right) \cdot \left(v + v\right)}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
Applied rewrites98.3%
Applied rewrites98.4%
Applied rewrites98.4%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(* cosTheta_i (/ cosTheta_O (* v (* (sinh (/ 1.0 v)) (+ v v))))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return cosTheta_i * (cosTheta_O / (v * (sinhf((1.0f / v)) * (v + v))));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = costheta_i * (costheta_o / (v * (sinh((1.0e0 / v)) * (v + v))))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(cosTheta_i * Float32(cosTheta_O / Float32(v * Float32(sinh(Float32(Float32(1.0) / v)) * Float32(v + v))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = cosTheta_i * (cosTheta_O / (v * (sinh((single(1.0) / v)) * (v + v)))); end
cosTheta\_i \cdot \frac{cosTheta\_O}{v \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot \left(v + v\right)\right)}
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
Applied rewrites98.3%
Applied rewrites98.4%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(*
(copysign 1.0 cosTheta_i)
(*
(fmax (fabs cosTheta_i) cosTheta_O)
(/
(fmin (fabs cosTheta_i) cosTheta_O)
(* v (* (sinh (/ 1.0 v)) (+ v v)))))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return copysignf(1.0f, cosTheta_i) * (fmaxf(fabsf(cosTheta_i), cosTheta_O) * (fminf(fabsf(cosTheta_i), cosTheta_O) / (v * (sinhf((1.0f / v)) * (v + v)))));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(copysign(Float32(1.0), cosTheta_i) * Float32(fmax(abs(cosTheta_i), cosTheta_O) * Float32(fmin(abs(cosTheta_i), cosTheta_O) / Float32(v * Float32(sinh(Float32(Float32(1.0) / v)) * Float32(v + v)))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (sign(cosTheta_i) * abs(single(1.0))) * (max(abs(cosTheta_i), cosTheta_O) * (min(abs(cosTheta_i), cosTheta_O) / (v * (sinh((single(1.0) / v)) * (v + v))))); end
\mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{max}\left(\left|cosTheta\_i\right|, cosTheta\_O\right) \cdot \frac{\mathsf{min}\left(\left|cosTheta\_i\right|, cosTheta\_O\right)}{v \cdot \left(\sinh \left(\frac{1}{v}\right) \cdot \left(v + v\right)\right)}\right)
Initial program 98.6%
Taylor expanded in sinTheta_i around 0
Applied rewrites98.3%
Applied rewrites98.3%
Applied rewrites98.4%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(let* ((t_0 (fmax (fabs cosTheta_i) (fabs cosTheta_O))))
(*
(copysign 1.0 cosTheta_i)
(*
(copysign 1.0 cosTheta_O)
(/
1.0
(*
v
(/
(/
(fma 2.0 (/ v t_0) (* 2.0 (/ (* sinTheta_O sinTheta_i) t_0)))
v)
(fmin (fabs cosTheta_i) (fabs cosTheta_O)))))))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float t_0 = fmaxf(fabsf(cosTheta_i), fabsf(cosTheta_O));
return copysignf(1.0f, cosTheta_i) * (copysignf(1.0f, cosTheta_O) * (1.0f / (v * ((fmaf(2.0f, (v / t_0), (2.0f * ((sinTheta_O * sinTheta_i) / t_0))) / v) / fminf(fabsf(cosTheta_i), fabsf(cosTheta_O))))));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = fmax(abs(cosTheta_i), abs(cosTheta_O)) return Float32(copysign(Float32(1.0), cosTheta_i) * Float32(copysign(Float32(1.0), cosTheta_O) * Float32(Float32(1.0) / Float32(v * Float32(Float32(fma(Float32(2.0), Float32(v / t_0), Float32(Float32(2.0) * Float32(Float32(sinTheta_O * sinTheta_i) / t_0))) / v) / fmin(abs(cosTheta_i), abs(cosTheta_O))))))) end
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right)\\
\mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{copysign}\left(1, cosTheta\_O\right) \cdot \frac{1}{v \cdot \frac{\frac{\mathsf{fma}\left(2, \frac{v}{t\_0}, 2 \cdot \frac{sinTheta\_O \cdot sinTheta\_i}{t\_0}\right)}{v}}{\mathsf{min}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right)}}\right)
\end{array}
Initial program 98.6%
Applied rewrites93.4%
Taylor expanded in v around inf
Applied rewrites36.4%
Taylor expanded in cosTheta_i around 0
Applied rewrites59.2%
Taylor expanded in v around 0
Applied rewrites59.2%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(let* ((t_0 (fmax (fabs cosTheta_i) (fabs cosTheta_O))))
(*
(copysign 1.0 cosTheta_i)
(*
(copysign 1.0 cosTheta_O)
(/
1.0
(*
v
(/
(fma
2.0
(/ (* sinTheta_O sinTheta_i) (* t_0 v))
(* 2.0 (/ 1.0 t_0)))
(fmin (fabs cosTheta_i) (fabs cosTheta_O)))))))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
float t_0 = fmaxf(fabsf(cosTheta_i), fabsf(cosTheta_O));
return copysignf(1.0f, cosTheta_i) * (copysignf(1.0f, cosTheta_O) * (1.0f / (v * (fmaf(2.0f, ((sinTheta_O * sinTheta_i) / (t_0 * v)), (2.0f * (1.0f / t_0))) / fminf(fabsf(cosTheta_i), fabsf(cosTheta_O))))));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) t_0 = fmax(abs(cosTheta_i), abs(cosTheta_O)) return Float32(copysign(Float32(1.0), cosTheta_i) * Float32(copysign(Float32(1.0), cosTheta_O) * Float32(Float32(1.0) / Float32(v * Float32(fma(Float32(2.0), Float32(Float32(sinTheta_O * sinTheta_i) / Float32(t_0 * v)), Float32(Float32(2.0) * Float32(Float32(1.0) / t_0))) / fmin(abs(cosTheta_i), abs(cosTheta_O))))))) end
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right)\\
\mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{copysign}\left(1, cosTheta\_O\right) \cdot \frac{1}{v \cdot \frac{\mathsf{fma}\left(2, \frac{sinTheta\_O \cdot sinTheta\_i}{t\_0 \cdot v}, 2 \cdot \frac{1}{t\_0}\right)}{\mathsf{min}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right)}}\right)
\end{array}
Initial program 98.6%
Applied rewrites93.4%
Taylor expanded in v around inf
Applied rewrites36.4%
Taylor expanded in cosTheta_i around 0
Applied rewrites59.2%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/ 1.0 (* v (/ 2.0 (* cosTheta_O cosTheta_i)))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 1.0f / (v * (2.0f / (cosTheta_O * cosTheta_i)));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = 1.0e0 / (v * (2.0e0 / (costheta_o * costheta_i)))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(1.0) / Float32(v * Float32(Float32(2.0) / Float32(cosTheta_O * cosTheta_i)))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(1.0) / (v * (single(2.0) / (cosTheta_O * cosTheta_i))); end
\frac{1}{v \cdot \frac{2}{cosTheta\_O \cdot cosTheta\_i}}
Initial program 98.6%
Applied rewrites93.4%
Taylor expanded in v around inf
Applied rewrites36.4%
Taylor expanded in cosTheta_i around 0
Applied rewrites59.2%
Taylor expanded in sinTheta_i around 0
Applied rewrites59.2%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/ 1.0 (/ (+ v v) (* cosTheta_i cosTheta_O))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 1.0f / ((v + v) / (cosTheta_i * cosTheta_O));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = 1.0e0 / ((v + v) / (costheta_i * costheta_o))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(1.0) / Float32(Float32(v + v) / Float32(cosTheta_i * cosTheta_O))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(1.0) / ((v + v) / (cosTheta_i * cosTheta_O)); end
\frac{1}{\frac{v + v}{cosTheta\_i \cdot cosTheta\_O}}
Initial program 98.6%
Applied rewrites93.4%
Taylor expanded in v around inf
Applied rewrites59.1%
Applied rewrites59.1%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(* (* 0.5 (* cosTheta_i cosTheta_O)) (/ 1.0 v)))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (0.5f * (cosTheta_i * cosTheta_O)) * (1.0f / v);
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (0.5e0 * (costheta_i * costheta_o)) * (1.0e0 / v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(0.5) * Float32(cosTheta_i * cosTheta_O)) * Float32(Float32(1.0) / v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (single(0.5) * (cosTheta_i * cosTheta_O)) * (single(1.0) / v); end
\left(0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)\right) \cdot \frac{1}{v}
Initial program 98.6%
Taylor expanded in v around inf
Applied rewrites58.5%
Applied rewrites58.5%
Applied rewrites58.6%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(/ (* 0.5 (* cosTheta_i cosTheta_O)) v))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return (0.5f * (cosTheta_i * cosTheta_O)) / v;
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = (0.5e0 * (costheta_i * costheta_o)) / v
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(Float32(0.5) * Float32(cosTheta_i * cosTheta_O)) / v) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (single(0.5) * (cosTheta_i * cosTheta_O)) / v; end
\frac{0.5 \cdot \left(cosTheta\_i \cdot cosTheta\_O\right)}{v}
Initial program 98.6%
Taylor expanded in v around inf
Applied rewrites58.5%
Applied rewrites58.6%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(* 0.5 (/ (* cosTheta_O cosTheta_i) v)))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 0.5f * ((cosTheta_O * cosTheta_i) / v);
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = 0.5e0 * ((costheta_o * costheta_i) / v)
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(0.5) * Float32(Float32(cosTheta_O * cosTheta_i) / v)) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.5) * ((cosTheta_O * cosTheta_i) / v); end
0.5 \cdot \frac{cosTheta\_O \cdot cosTheta\_i}{v}
Initial program 98.6%
Taylor expanded in v around inf
Applied rewrites58.5%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(*
(copysign 1.0 cosTheta_i)
(*
(copysign 1.0 cosTheta_O)
(*
0.5
(*
(fmin (fabs cosTheta_i) (fabs cosTheta_O))
(/ (fmax (fabs cosTheta_i) (fabs cosTheta_O)) v))))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return copysignf(1.0f, cosTheta_i) * (copysignf(1.0f, cosTheta_O) * (0.5f * (fminf(fabsf(cosTheta_i), fabsf(cosTheta_O)) * (fmaxf(fabsf(cosTheta_i), fabsf(cosTheta_O)) / v))));
}
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(copysign(Float32(1.0), cosTheta_i) * Float32(copysign(Float32(1.0), cosTheta_O) * Float32(Float32(0.5) * Float32(fmin(abs(cosTheta_i), abs(cosTheta_O)) * Float32(fmax(abs(cosTheta_i), abs(cosTheta_O)) / v))))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = (sign(cosTheta_i) * abs(single(1.0))) * ((sign(cosTheta_O) * abs(single(1.0))) * (single(0.5) * (min(abs(cosTheta_i), abs(cosTheta_O)) * (max(abs(cosTheta_i), abs(cosTheta_O)) / v)))); end
\mathsf{copysign}\left(1, cosTheta\_i\right) \cdot \left(\mathsf{copysign}\left(1, cosTheta\_O\right) \cdot \left(0.5 \cdot \left(\mathsf{min}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right) \cdot \frac{\mathsf{max}\left(\left|cosTheta\_i\right|, \left|cosTheta\_O\right|\right)}{v}\right)\right)\right)
Initial program 98.6%
Taylor expanded in v around inf
Applied rewrites58.5%
Applied rewrites58.5%
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:precision binary32
:pre (and (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)))
(< 0.1 v))
(<= v 1.5707964))
(*
0.5
(* (fmax cosTheta_i cosTheta_O) (/ (fmin cosTheta_i cosTheta_O) v))))float code(float cosTheta_i, float cosTheta_O, float sinTheta_i, float sinTheta_O, float v) {
return 0.5f * (fmaxf(cosTheta_i, cosTheta_O) * (fminf(cosTheta_i, cosTheta_O) / v));
}
real(4) function code(costheta_i, costheta_o, sintheta_i, sintheta_o, v)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: costheta_o
real(4), intent (in) :: sintheta_i
real(4), intent (in) :: sintheta_o
real(4), intent (in) :: v
code = 0.5e0 * (fmax(costheta_i, costheta_o) * (fmin(costheta_i, costheta_o) / v))
end function
function code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) return Float32(Float32(0.5) * Float32(fmax(cosTheta_i, cosTheta_O) * Float32(fmin(cosTheta_i, cosTheta_O) / v))) end
function tmp = code(cosTheta_i, cosTheta_O, sinTheta_i, sinTheta_O, v) tmp = single(0.5) * (max(cosTheta_i, cosTheta_O) * (min(cosTheta_i, cosTheta_O) / v)); end
0.5 \cdot \left(\mathsf{max}\left(cosTheta\_i, cosTheta\_O\right) \cdot \frac{\mathsf{min}\left(cosTheta\_i, cosTheta\_O\right)}{v}\right)
Initial program 98.6%
Taylor expanded in v around inf
Applied rewrites58.5%
Applied rewrites58.5%
herbie shell --seed 2026089 +o generate:egglog
(FPCore (cosTheta_i cosTheta_O sinTheta_i sinTheta_O v)
:name "HairBSDF, Mp, upper"
:precision binary32
:pre (and (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))) (< 0.1 v)) (<= v 1.5707964))
(/ (* (exp (- (/ (* sinTheta_i sinTheta_O) v))) (/ (* cosTheta_i cosTheta_O) v)) (* (* (sinh (/ 1.0 v)) 2.0) v)))