
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 95.0%
+-commutative95.0%
unpow295.0%
unpow295.0%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-30) (* (sin th) (/ (sin ky) (fabs (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-30) {
tmp = sin(th) * (sin(ky) / fabs(sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 1d-30) then
tmp = sin(th) * (sin(ky) / abs(sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-30) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-30: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-30) tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-30) tmp = sin(th) * (sin(ky) / abs(sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-30], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-30}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1e-30Initial program 93.5%
unpow293.5%
sin-mult80.3%
Applied egg-rr80.3%
div-sub80.3%
+-inverses80.3%
cos-080.3%
metadata-eval80.3%
count-280.3%
*-commutative80.3%
Simplified80.3%
Taylor expanded in ky around 0 37.6%
sqr-sin-a51.6%
rem-sqrt-square55.7%
Applied egg-rr55.7%
if 1e-30 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.4%
Final simplification56.9%
(FPCore (kx ky th) :precision binary64 (if (<= kx 0.025) (* (sin th) (/ (sin ky) (hypot (sin ky) kx))) (* (sin th) (/ (sin ky) (fabs (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 0.025) {
tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx));
} else {
tmp = sin(th) * (sin(ky) / fabs(sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 0.025) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.hypot(Math.sin(ky), kx));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.abs(Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 0.025: tmp = math.sin(th) * (math.sin(ky) / math.hypot(math.sin(ky), kx)) else: tmp = math.sin(th) * (math.sin(ky) / math.fabs(math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 0.025) tmp = Float64(sin(th) * Float64(sin(ky) / hypot(sin(ky), kx))); else tmp = Float64(sin(th) * Float64(sin(ky) / abs(sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 0.025) tmp = sin(th) * (sin(ky) / hypot(sin(ky), kx)); else tmp = sin(th) * (sin(ky) / abs(sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 0.025], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + kx ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 0.025:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, kx\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\left|\sin kx\right|}\\
\end{array}
\end{array}
if kx < 0.025000000000000001Initial program 93.5%
+-commutative93.5%
unpow293.5%
unpow293.5%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 71.3%
if 0.025000000000000001 < kx Initial program 99.4%
unpow299.4%
sin-mult99.3%
Applied egg-rr99.3%
div-sub99.3%
+-inverses99.3%
cos-099.3%
metadata-eval99.3%
count-299.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in ky around 0 59.9%
sqr-sin-a60.1%
rem-sqrt-square60.1%
Applied egg-rr60.1%
Final simplification68.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 1e-30) (* (sin th) (/ ky (fabs (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 1e-30) {
tmp = sin(th) * (ky / fabs(sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 1d-30) then
tmp = sin(th) * (ky / abs(sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 1e-30) {
tmp = Math.sin(th) * (ky / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 1e-30: tmp = math.sin(th) * (ky / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 1e-30) tmp = Float64(sin(th) * Float64(ky / abs(sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 1e-30) tmp = sin(th) * (ky / abs(sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 1e-30], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 10^{-30}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 1e-30Initial program 93.5%
Taylor expanded in ky around 0 30.4%
add-sqr-sqrt25.1%
sqrt-prod48.4%
rem-sqrt-square52.4%
Applied egg-rr52.4%
if 1e-30 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 60.4%
Final simplification54.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-117) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-117) {
tmp = sin(th) * (ky / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= 2d-117) then
tmp = sin(th) * (ky / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= 2e-117) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-117: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-117) tmp = Float64(sin(th) * Float64(ky / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 2e-117) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-117], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-117}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000006e-117Initial program 92.8%
Taylor expanded in ky around 0 30.2%
if 2.00000000000000006e-117 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 56.5%
Final simplification38.7%
(FPCore (kx ky th)
:precision binary64
(if (<= ky -0.95)
(sin th)
(if (<= ky -5.5e-117)
(/ ky (/ (sin kx) th))
(if (<= ky 2.3e-125) (* (sin th) (/ ky kx)) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -0.95) {
tmp = sin(th);
} else if (ky <= -5.5e-117) {
tmp = ky / (sin(kx) / th);
} else if (ky <= 2.3e-125) {
tmp = sin(th) * (ky / kx);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (ky <= (-0.95d0)) then
tmp = sin(th)
else if (ky <= (-5.5d-117)) then
tmp = ky / (sin(kx) / th)
else if (ky <= 2.3d-125) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -0.95) {
tmp = Math.sin(th);
} else if (ky <= -5.5e-117) {
tmp = ky / (Math.sin(kx) / th);
} else if (ky <= 2.3e-125) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -0.95: tmp = math.sin(th) elif ky <= -5.5e-117: tmp = ky / (math.sin(kx) / th) elif ky <= 2.3e-125: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -0.95) tmp = sin(th); elseif (ky <= -5.5e-117) tmp = Float64(ky / Float64(sin(kx) / th)); elseif (ky <= 2.3e-125) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -0.95) tmp = sin(th); elseif (ky <= -5.5e-117) tmp = ky / (sin(kx) / th); elseif (ky <= 2.3e-125) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -0.95], N[Sin[th], $MachinePrecision], If[LessEqual[ky, -5.5e-117], N[(ky / N[(N[Sin[kx], $MachinePrecision] / th), $MachinePrecision]), $MachinePrecision], If[LessEqual[ky, 2.3e-125], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -0.95:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq -5.5 \cdot 10^{-117}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\
\mathbf{elif}\;ky \leq 2.3 \cdot 10^{-125}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -0.94999999999999996 or 2.2999999999999999e-125 < ky Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 32.8%
if -0.94999999999999996 < ky < -5.50000000000000025e-117Initial program 99.8%
Taylor expanded in ky around 0 34.3%
Taylor expanded in th around 0 21.6%
associate-/l*21.5%
Simplified21.5%
if -5.50000000000000025e-117 < ky < 2.2999999999999999e-125Initial program 83.3%
Taylor expanded in ky around 0 55.7%
Taylor expanded in kx around 0 35.7%
Final simplification32.4%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -0.95) (not (<= ky 1.1e-123))) (sin th) (* (sin th) (/ ky kx))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -0.95) || !(ky <= 1.1e-123)) {
tmp = sin(th);
} else {
tmp = sin(th) * (ky / kx);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((ky <= (-0.95d0)) .or. (.not. (ky <= 1.1d-123))) then
tmp = sin(th)
else
tmp = sin(th) * (ky / kx)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -0.95) || !(ky <= 1.1e-123)) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (ky / kx);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -0.95) or not (ky <= 1.1e-123): tmp = math.sin(th) else: tmp = math.sin(th) * (ky / kx) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -0.95) || !(ky <= 1.1e-123)) tmp = sin(th); else tmp = Float64(sin(th) * Float64(ky / kx)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -0.95) || ~((ky <= 1.1e-123))) tmp = sin(th); else tmp = sin(th) * (ky / kx); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -0.95], N[Not[LessEqual[ky, 1.1e-123]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -0.95 \lor \neg \left(ky \leq 1.1 \cdot 10^{-123}\right):\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\end{array}
\end{array}
if ky < -0.94999999999999996 or 1.10000000000000003e-123 < ky Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 32.8%
if -0.94999999999999996 < ky < 1.10000000000000003e-123Initial program 87.8%
Taylor expanded in ky around 0 49.8%
Taylor expanded in kx around 0 28.9%
Final simplification31.2%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -0.95) (not (<= ky 1.35e-126))) (sin th) (/ ky (/ kx th))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -0.95) || !(ky <= 1.35e-126)) {
tmp = sin(th);
} else {
tmp = ky / (kx / th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if ((ky <= (-0.95d0)) .or. (.not. (ky <= 1.35d-126))) then
tmp = sin(th)
else
tmp = ky / (kx / th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -0.95) || !(ky <= 1.35e-126)) {
tmp = Math.sin(th);
} else {
tmp = ky / (kx / th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -0.95) or not (ky <= 1.35e-126): tmp = math.sin(th) else: tmp = ky / (kx / th) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -0.95) || !(ky <= 1.35e-126)) tmp = sin(th); else tmp = Float64(ky / Float64(kx / th)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -0.95) || ~((ky <= 1.35e-126))) tmp = sin(th); else tmp = ky / (kx / th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -0.95], N[Not[LessEqual[ky, 1.35e-126]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -0.95 \lor \neg \left(ky \leq 1.35 \cdot 10^{-126}\right):\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\frac{ky}{\frac{kx}{th}}\\
\end{array}
\end{array}
if ky < -0.94999999999999996 or 1.34999999999999998e-126 < ky Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 32.8%
if -0.94999999999999996 < ky < 1.34999999999999998e-126Initial program 87.8%
Taylor expanded in ky around 0 49.8%
Taylor expanded in kx around 0 28.9%
Taylor expanded in th around 0 17.4%
associate-/l*20.7%
Simplified20.7%
Final simplification28.0%
(FPCore (kx ky th) :precision binary64 (/ ky (/ kx th)))
double code(double kx, double ky, double th) {
return ky / (kx / th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = ky / (kx / th)
end function
public static double code(double kx, double ky, double th) {
return ky / (kx / th);
}
def code(kx, ky, th): return ky / (kx / th)
function code(kx, ky, th) return Float64(ky / Float64(kx / th)) end
function tmp = code(kx, ky, th) tmp = ky / (kx / th); end
code[kx_, ky_, th_] := N[(ky / N[(kx / th), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{ky}{\frac{kx}{th}}
\end{array}
Initial program 95.0%
Taylor expanded in ky around 0 23.6%
Taylor expanded in kx around 0 14.2%
Taylor expanded in th around 0 8.9%
associate-/l*10.3%
Simplified10.3%
Final simplification10.3%
herbie shell --seed 2023301
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))