
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(let* ((t_0 (* ecc (sin phi0))))
(/ (* k0 (sqrt one_es)) (- 1.0 (* t_0 t_0)))))double code(double k0, double one_es, double ecc, double phi0) {
double t_0 = ecc * sin(phi0);
return (k0 * sqrt(one_es)) / (1.0 - (t_0 * t_0));
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
real(8) :: t_0
t_0 = ecc * sin(phi0)
code = (k0 * sqrt(one_es)) / (1.0d0 - (t_0 * t_0))
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
double t_0 = ecc * Math.sin(phi0);
return (k0 * Math.sqrt(one_es)) / (1.0 - (t_0 * t_0));
}
def code(k0, one_es, ecc, phi0): t_0 = ecc * math.sin(phi0) return (k0 * math.sqrt(one_es)) / (1.0 - (t_0 * t_0))
function code(k0, one_es, ecc, phi0) t_0 = Float64(ecc * sin(phi0)) return Float64(Float64(k0 * sqrt(one_es)) / Float64(1.0 - Float64(t_0 * t_0))) end
function tmp = code(k0, one_es, ecc, phi0) t_0 = ecc * sin(phi0); tmp = (k0 * sqrt(one_es)) / (1.0 - (t_0 * t_0)); end
code[k0_, one$95$es_, ecc_, phi0_] := Block[{t$95$0 = N[(ecc * N[Sin[phi0], $MachinePrecision]), $MachinePrecision]}, N[(N[(k0 * N[Sqrt[one$95$es], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = LET t_0 = (ecc * (sin(phi0))) IN (k0 * (sqrt(one_es))) / ((1) - (t_0 * t_0)) END code
\begin{array}{l}
t_0 := ecc \cdot \sin phi0\\
\frac{k0 \cdot \sqrt{one\_es}}{1 - t\_0 \cdot t\_0}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(let* ((t_0 (* ecc (sin phi0))))
(/ (* k0 (sqrt one_es)) (- 1.0 (* t_0 t_0)))))double code(double k0, double one_es, double ecc, double phi0) {
double t_0 = ecc * sin(phi0);
return (k0 * sqrt(one_es)) / (1.0 - (t_0 * t_0));
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
real(8) :: t_0
t_0 = ecc * sin(phi0)
code = (k0 * sqrt(one_es)) / (1.0d0 - (t_0 * t_0))
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
double t_0 = ecc * Math.sin(phi0);
return (k0 * Math.sqrt(one_es)) / (1.0 - (t_0 * t_0));
}
def code(k0, one_es, ecc, phi0): t_0 = ecc * math.sin(phi0) return (k0 * math.sqrt(one_es)) / (1.0 - (t_0 * t_0))
function code(k0, one_es, ecc, phi0) t_0 = Float64(ecc * sin(phi0)) return Float64(Float64(k0 * sqrt(one_es)) / Float64(1.0 - Float64(t_0 * t_0))) end
function tmp = code(k0, one_es, ecc, phi0) t_0 = ecc * sin(phi0); tmp = (k0 * sqrt(one_es)) / (1.0 - (t_0 * t_0)); end
code[k0_, one$95$es_, ecc_, phi0_] := Block[{t$95$0 = N[(ecc * N[Sin[phi0], $MachinePrecision]), $MachinePrecision]}, N[(N[(k0 * N[Sqrt[one$95$es], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = LET t_0 = (ecc * (sin(phi0))) IN (k0 * (sqrt(one_es))) / ((1) - (t_0 * t_0)) END code
\begin{array}{l}
t_0 := ecc \cdot \sin phi0\\
\frac{k0 \cdot \sqrt{one\_es}}{1 - t\_0 \cdot t\_0}
\end{array}
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(*
(/
(sqrt one_es)
(fma (fma (cos (+ phi0 phi0)) 0.5 -0.5) (* ecc ecc) 1.0))
k0))double code(double k0, double one_es, double ecc, double phi0) {
return (sqrt(one_es) / fma(fma(cos((phi0 + phi0)), 0.5, -0.5), (ecc * ecc), 1.0)) * k0;
}
function code(k0, one_es, ecc, phi0) return Float64(Float64(sqrt(one_es) / fma(fma(cos(Float64(phi0 + phi0)), 0.5, -0.5), Float64(ecc * ecc), 1.0)) * k0) end
code[k0_, one$95$es_, ecc_, phi0_] := N[(N[(N[Sqrt[one$95$es], $MachinePrecision] / N[(N[(N[Cos[N[(phi0 + phi0), $MachinePrecision]], $MachinePrecision] * 0.5 + -0.5), $MachinePrecision] * N[(ecc * ecc), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * k0), $MachinePrecision]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = ((sqrt(one_es)) / (((((cos((phi0 + phi0))) * (5e-1)) + (-5e-1)) * (ecc * ecc)) + (1))) * k0 END code
\frac{\sqrt{one\_es}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(phi0 + phi0\right), 0.5, -0.5\right), ecc \cdot ecc, 1\right)} \cdot k0
Initial program 99.6%
Applied rewrites99.6%
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(/ k0 (sqrt (/ 1.0 one_es))))double code(double k0, double one_es, double ecc, double phi0) {
return k0 / sqrt((1.0 / one_es));
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
code = k0 / sqrt((1.0d0 / one_es))
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
return k0 / Math.sqrt((1.0 / one_es));
}
def code(k0, one_es, ecc, phi0): return k0 / math.sqrt((1.0 / one_es))
function code(k0, one_es, ecc, phi0) return Float64(k0 / sqrt(Float64(1.0 / one_es))) end
function tmp = code(k0, one_es, ecc, phi0) tmp = k0 / sqrt((1.0 / one_es)); end
code[k0_, one$95$es_, ecc_, phi0_] := N[(k0 / N[Sqrt[N[(1.0 / one$95$es), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = k0 / (sqrt(((1) / one_es))) END code
\frac{k0}{\sqrt{\frac{1}{one\_es}}}
Initial program 99.6%
Taylor expanded in one_es around inf
Applied rewrites99.5%
Applied rewrites98.3%
Applied rewrites88.0%
Taylor expanded in one_es around inf
Applied rewrites99.2%
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(* (sqrt one_es) k0))double code(double k0, double one_es, double ecc, double phi0) {
return sqrt(one_es) * k0;
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
code = sqrt(one_es) * k0
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
return Math.sqrt(one_es) * k0;
}
def code(k0, one_es, ecc, phi0): return math.sqrt(one_es) * k0
function code(k0, one_es, ecc, phi0) return Float64(sqrt(one_es) * k0) end
function tmp = code(k0, one_es, ecc, phi0) tmp = sqrt(one_es) * k0; end
code[k0_, one$95$es_, ecc_, phi0_] := N[(N[Sqrt[one$95$es], $MachinePrecision] * k0), $MachinePrecision]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = (sqrt(one_es)) * k0 END code
\sqrt{one\_es} \cdot k0
Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.2%
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(* one_es k0))double code(double k0, double one_es, double ecc, double phi0) {
return one_es * k0;
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
code = one_es * k0
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
return one_es * k0;
}
def code(k0, one_es, ecc, phi0): return one_es * k0
function code(k0, one_es, ecc, phi0) return Float64(one_es * k0) end
function tmp = code(k0, one_es, ecc, phi0) tmp = one_es * k0; end
code[k0_, one$95$es_, ecc_, phi0_] := N[(one$95$es * k0), $MachinePrecision]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = one_es * k0 END code
one\_es \cdot k0
Initial program 99.6%
Applied rewrites99.6%
Applied rewrites18.6%
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(* k0 k0))double code(double k0, double one_es, double ecc, double phi0) {
return k0 * k0;
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
code = k0 * k0
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
return k0 * k0;
}
def code(k0, one_es, ecc, phi0): return k0 * k0
function code(k0, one_es, ecc, phi0) return Float64(k0 * k0) end
function tmp = code(k0, one_es, ecc, phi0) tmp = k0 * k0; end
code[k0_, one$95$es_, ecc_, phi0_] := N[(k0 * k0), $MachinePrecision]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = k0 * k0 END code
k0 \cdot k0
Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.2%
Applied rewrites99.1%
Applied rewrites17.6%
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(if (<= (* k0 (sqrt one_es)) 1e-198) (- k0 k0) (* k0 (fabs phi0))))double code(double k0, double one_es, double ecc, double phi0) {
double tmp;
if ((k0 * sqrt(one_es)) <= 1e-198) {
tmp = k0 - k0;
} else {
tmp = k0 * fabs(phi0);
}
return tmp;
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
real(8) :: tmp
if ((k0 * sqrt(one_es)) <= 1d-198) then
tmp = k0 - k0
else
tmp = k0 * abs(phi0)
end if
code = tmp
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
double tmp;
if ((k0 * Math.sqrt(one_es)) <= 1e-198) {
tmp = k0 - k0;
} else {
tmp = k0 * Math.abs(phi0);
}
return tmp;
}
def code(k0, one_es, ecc, phi0): tmp = 0 if (k0 * math.sqrt(one_es)) <= 1e-198: tmp = k0 - k0 else: tmp = k0 * math.fabs(phi0) return tmp
function code(k0, one_es, ecc, phi0) tmp = 0.0 if (Float64(k0 * sqrt(one_es)) <= 1e-198) tmp = Float64(k0 - k0); else tmp = Float64(k0 * abs(phi0)); end return tmp end
function tmp_2 = code(k0, one_es, ecc, phi0) tmp = 0.0; if ((k0 * sqrt(one_es)) <= 1e-198) tmp = k0 - k0; else tmp = k0 * abs(phi0); end tmp_2 = tmp; end
code[k0_, one$95$es_, ecc_, phi0_] := If[LessEqual[N[(k0 * N[Sqrt[one$95$es], $MachinePrecision]), $MachinePrecision], 1e-198], N[(k0 - k0), $MachinePrecision], N[(k0 * N[Abs[phi0], $MachinePrecision]), $MachinePrecision]]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = LET tmp = IF ((k0 * (sqrt(one_es))) <= (9999999999999999124802099224533715278754906771643890943097115679663244864890241489099268701300224747096620592506163636511458147080229307187686231418190870453248079045903136497403860177328871032921253477527517381647903616019374090502989225614211093036170293774649807043557627102989961482478123917402578427471263639364172725828851513302974451006929804660161786807414215058738258826728830198486282936879197000185087711763102436423213435887235808111997818538852504458228488519455634531141186016611754894256591796875e-709)) THEN (k0 - k0) ELSE (k0 * (abs(phi0))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;k0 \cdot \sqrt{one\_es} \leq 10^{-198}:\\
\;\;\;\;k0 - k0\\
\mathbf{else}:\\
\;\;\;\;k0 \cdot \left|phi0\right|\\
\end{array}
if (*.f64 k0 (sqrt.f64 one_es)) < 9.9999999999999991e-199Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.2%
Applied rewrites99.1%
Applied rewrites9.1%
if 9.9999999999999991e-199 < (*.f64 k0 (sqrt.f64 one_es)) Initial program 99.6%
Taylor expanded in one_es around inf
Applied rewrites99.5%
Applied rewrites98.3%
Applied rewrites99.0%
Applied rewrites7.5%
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
(if (<= (* k0 (sqrt one_es)) 1e-198) (- k0 k0) (sqrt k0)))double code(double k0, double one_es, double ecc, double phi0) {
double tmp;
if ((k0 * sqrt(one_es)) <= 1e-198) {
tmp = k0 - k0;
} else {
tmp = sqrt(k0);
}
return tmp;
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
real(8) :: tmp
if ((k0 * sqrt(one_es)) <= 1d-198) then
tmp = k0 - k0
else
tmp = sqrt(k0)
end if
code = tmp
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
double tmp;
if ((k0 * Math.sqrt(one_es)) <= 1e-198) {
tmp = k0 - k0;
} else {
tmp = Math.sqrt(k0);
}
return tmp;
}
def code(k0, one_es, ecc, phi0): tmp = 0 if (k0 * math.sqrt(one_es)) <= 1e-198: tmp = k0 - k0 else: tmp = math.sqrt(k0) return tmp
function code(k0, one_es, ecc, phi0) tmp = 0.0 if (Float64(k0 * sqrt(one_es)) <= 1e-198) tmp = Float64(k0 - k0); else tmp = sqrt(k0); end return tmp end
function tmp_2 = code(k0, one_es, ecc, phi0) tmp = 0.0; if ((k0 * sqrt(one_es)) <= 1e-198) tmp = k0 - k0; else tmp = sqrt(k0); end tmp_2 = tmp; end
code[k0_, one$95$es_, ecc_, phi0_] := If[LessEqual[N[(k0 * N[Sqrt[one$95$es], $MachinePrecision]), $MachinePrecision], 1e-198], N[(k0 - k0), $MachinePrecision], N[Sqrt[k0], $MachinePrecision]]
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = LET tmp = IF ((k0 * (sqrt(one_es))) <= (9999999999999999124802099224533715278754906771643890943097115679663244864890241489099268701300224747096620592506163636511458147080229307187686231418190870453248079045903136497403860177328871032921253477527517381647903616019374090502989225614211093036170293774649807043557627102989961482478123917402578427471263639364172725828851513302974451006929804660161786807414215058738258826728830198486282936879197000185087711763102436423213435887235808111997818538852504458228488519455634531141186016611754894256591796875e-709)) THEN (k0 - k0) ELSE (sqrt(k0)) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;k0 \cdot \sqrt{one\_es} \leq 10^{-198}:\\
\;\;\;\;k0 - k0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{k0}\\
\end{array}
if (*.f64 k0 (sqrt.f64 one_es)) < 9.9999999999999991e-199Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.2%
Applied rewrites99.1%
Applied rewrites9.1%
if 9.9999999999999991e-199 < (*.f64 k0 (sqrt.f64 one_es)) Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.2%
Applied rewrites99.1%
Applied rewrites6.6%
(FPCore (k0 one_es ecc phi0)
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0))
(< ecc 1.0))
k0)double code(double k0, double one_es, double ecc, double phi0) {
return k0;
}
real(8) function code(k0, one_es, ecc, phi0)
use fmin_fmax_functions
real(8), intent (in) :: k0
real(8), intent (in) :: one_es
real(8), intent (in) :: ecc
real(8), intent (in) :: phi0
code = k0
end function
public static double code(double k0, double one_es, double ecc, double phi0) {
return k0;
}
def code(k0, one_es, ecc, phi0): return k0
function code(k0, one_es, ecc, phi0) return k0 end
function tmp = code(k0, one_es, ecc, phi0) tmp = k0; end
code[k0_, one$95$es_, ecc_, phi0_] := k0
f(k0, one_es, ecc, phi0): k0 in [0, +inf], one_es in [0, +inf], ecc in [0, 1], phi0 in [-inf, +inf] code: THEORY BEGIN f(k0, one_es, ecc, phi0: real): real = k0 END code
k0
Initial program 99.6%
Taylor expanded in one_es around inf
Applied rewrites99.5%
Applied rewrites98.3%
Applied rewrites99.0%
Applied rewrites7.2%
herbie shell --seed 2026050 +o generate:egglog
(FPCore (k0 one_es ecc phi0)
:name "init-kR"
:precision binary64
:pre (and (and (and (> k0 0.0) (> one_es 0.0)) (> ecc 0.0)) (< ecc 1.0))
(/ (* k0 (sqrt one_es)) (- 1.0 (* (* ecc (sin phi0)) (* ecc (sin phi0))))))