
(FPCore (u v cosrot sinrot u0) :precision binary64 :pre TRUE (+ (* v cosrot) (* (- u u0) sinrot)))
double code(double u, double v, double cosrot, double sinrot, double u0) {
return (v * cosrot) + ((u - u0) * sinrot);
}
real(8) function code(u, v, cosrot, sinrot, u0)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: cosrot
real(8), intent (in) :: sinrot
real(8), intent (in) :: u0
code = (v * cosrot) + ((u - u0) * sinrot)
end function
public static double code(double u, double v, double cosrot, double sinrot, double u0) {
return (v * cosrot) + ((u - u0) * sinrot);
}
def code(u, v, cosrot, sinrot, u0): return (v * cosrot) + ((u - u0) * sinrot)
function code(u, v, cosrot, sinrot, u0) return Float64(Float64(v * cosrot) + Float64(Float64(u - u0) * sinrot)) end
function tmp = code(u, v, cosrot, sinrot, u0) tmp = (v * cosrot) + ((u - u0) * sinrot); end
code[u_, v_, cosrot_, sinrot_, u0_] := N[(N[(v * cosrot), $MachinePrecision] + N[(N[(u - u0), $MachinePrecision] * sinrot), $MachinePrecision]), $MachinePrecision]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = (v * cosrot) + ((u - u0) * sinrot) END code
v \cdot cosrot + \left(u - u0\right) \cdot sinrot
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (u v cosrot sinrot u0) :precision binary64 :pre TRUE (+ (* v cosrot) (* (- u u0) sinrot)))
double code(double u, double v, double cosrot, double sinrot, double u0) {
return (v * cosrot) + ((u - u0) * sinrot);
}
real(8) function code(u, v, cosrot, sinrot, u0)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: cosrot
real(8), intent (in) :: sinrot
real(8), intent (in) :: u0
code = (v * cosrot) + ((u - u0) * sinrot)
end function
public static double code(double u, double v, double cosrot, double sinrot, double u0) {
return (v * cosrot) + ((u - u0) * sinrot);
}
def code(u, v, cosrot, sinrot, u0): return (v * cosrot) + ((u - u0) * sinrot)
function code(u, v, cosrot, sinrot, u0) return Float64(Float64(v * cosrot) + Float64(Float64(u - u0) * sinrot)) end
function tmp = code(u, v, cosrot, sinrot, u0) tmp = (v * cosrot) + ((u - u0) * sinrot); end
code[u_, v_, cosrot_, sinrot_, u0_] := N[(N[(v * cosrot), $MachinePrecision] + N[(N[(u - u0), $MachinePrecision] * sinrot), $MachinePrecision]), $MachinePrecision]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = (v * cosrot) + ((u - u0) * sinrot) END code
v \cdot cosrot + \left(u - u0\right) \cdot sinrot
(FPCore (u v cosrot sinrot u0) :precision binary64 :pre TRUE (fma (- u u0) sinrot (* v cosrot)))
double code(double u, double v, double cosrot, double sinrot, double u0) {
return fma((u - u0), sinrot, (v * cosrot));
}
function code(u, v, cosrot, sinrot, u0) return fma(Float64(u - u0), sinrot, Float64(v * cosrot)) end
code[u_, v_, cosrot_, sinrot_, u0_] := N[(N[(u - u0), $MachinePrecision] * sinrot + N[(v * cosrot), $MachinePrecision]), $MachinePrecision]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = ((u - u0) * sinrot) + (v * cosrot) END code
\mathsf{fma}\left(u - u0, sinrot, v \cdot cosrot\right)
Initial program 98.8%
Applied rewrites99.4%
(FPCore (u v cosrot sinrot u0)
:precision binary64
:pre TRUE
(let* ((t_0 (fma (- u0) sinrot (* cosrot v))))
(if (<= u0 -3.6281267418831816e+31)
t_0
(if (<= u0 5.714373608685782e+32)
(fma cosrot v (* sinrot u))
t_0))))double code(double u, double v, double cosrot, double sinrot, double u0) {
double t_0 = fma(-u0, sinrot, (cosrot * v));
double tmp;
if (u0 <= -3.6281267418831816e+31) {
tmp = t_0;
} else if (u0 <= 5.714373608685782e+32) {
tmp = fma(cosrot, v, (sinrot * u));
} else {
tmp = t_0;
}
return tmp;
}
function code(u, v, cosrot, sinrot, u0) t_0 = fma(Float64(-u0), sinrot, Float64(cosrot * v)) tmp = 0.0 if (u0 <= -3.6281267418831816e+31) tmp = t_0; elseif (u0 <= 5.714373608685782e+32) tmp = fma(cosrot, v, Float64(sinrot * u)); else tmp = t_0; end return tmp end
code[u_, v_, cosrot_, sinrot_, u0_] := Block[{t$95$0 = N[((-u0) * sinrot + N[(cosrot * v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[u0, -3.6281267418831816e+31], t$95$0, If[LessEqual[u0, 5.714373608685782e+32], N[(cosrot * v + N[(sinrot * u), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = LET t_0 = (((- u0) * sinrot) + (cosrot * v)) IN LET tmp_1 = IF (u0 <= (571437360868578164535154981208064)) THEN ((cosrot * v) + (sinrot * u)) ELSE t_0 ENDIF IN LET tmp = IF (u0 <= (-36281267418831816064245553954816)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := \mathsf{fma}\left(-u0, sinrot, cosrot \cdot v\right)\\
\mathbf{if}\;u0 \leq -3.6281267418831816 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;u0 \leq 5.714373608685782 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(cosrot, v, sinrot \cdot u\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if u0 < -3.6281267418831816e31 or 5.7143736086857816e32 < u0 Initial program 98.8%
Applied rewrites98.1%
Taylor expanded in u around 0
Applied rewrites70.6%
Applied rewrites71.0%
if -3.6281267418831816e31 < u0 < 5.7143736086857816e32Initial program 98.8%
Taylor expanded in u0 around 0
Applied rewrites70.8%
(FPCore (u v cosrot sinrot u0)
:precision binary64
:pre TRUE
(let* ((t_0 (- (* cosrot v) (* sinrot u0))))
(if (<= u0 -3.6281267418831816e+31)
t_0
(if (<= u0 5.714373608685782e+32)
(fma cosrot v (* sinrot u))
t_0))))double code(double u, double v, double cosrot, double sinrot, double u0) {
double t_0 = (cosrot * v) - (sinrot * u0);
double tmp;
if (u0 <= -3.6281267418831816e+31) {
tmp = t_0;
} else if (u0 <= 5.714373608685782e+32) {
tmp = fma(cosrot, v, (sinrot * u));
} else {
tmp = t_0;
}
return tmp;
}
function code(u, v, cosrot, sinrot, u0) t_0 = Float64(Float64(cosrot * v) - Float64(sinrot * u0)) tmp = 0.0 if (u0 <= -3.6281267418831816e+31) tmp = t_0; elseif (u0 <= 5.714373608685782e+32) tmp = fma(cosrot, v, Float64(sinrot * u)); else tmp = t_0; end return tmp end
code[u_, v_, cosrot_, sinrot_, u0_] := Block[{t$95$0 = N[(N[(cosrot * v), $MachinePrecision] - N[(sinrot * u0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[u0, -3.6281267418831816e+31], t$95$0, If[LessEqual[u0, 5.714373608685782e+32], N[(cosrot * v + N[(sinrot * u), $MachinePrecision]), $MachinePrecision], t$95$0]]]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = LET t_0 = ((cosrot * v) - (sinrot * u0)) IN LET tmp_1 = IF (u0 <= (571437360868578164535154981208064)) THEN ((cosrot * v) + (sinrot * u)) ELSE t_0 ENDIF IN LET tmp = IF (u0 <= (-36281267418831816064245553954816)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := cosrot \cdot v - sinrot \cdot u0\\
\mathbf{if}\;u0 \leq -3.6281267418831816 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;u0 \leq 5.714373608685782 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(cosrot, v, sinrot \cdot u\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if u0 < -3.6281267418831816e31 or 5.7143736086857816e32 < u0 Initial program 98.8%
Applied rewrites98.1%
Taylor expanded in u around 0
Applied rewrites70.6%
if -3.6281267418831816e31 < u0 < 5.7143736086857816e32Initial program 98.8%
Taylor expanded in u0 around 0
Applied rewrites70.8%
(FPCore (u v cosrot sinrot u0)
:precision binary64
:pre TRUE
(let* ((t_0 (* (- u u0) sinrot)) (t_1 (* sinrot (- u u0))))
(if (<= t_0 -1e+142)
t_1
(if (<= t_0 5e+46) (fma cosrot v (* sinrot u)) t_1))))double code(double u, double v, double cosrot, double sinrot, double u0) {
double t_0 = (u - u0) * sinrot;
double t_1 = sinrot * (u - u0);
double tmp;
if (t_0 <= -1e+142) {
tmp = t_1;
} else if (t_0 <= 5e+46) {
tmp = fma(cosrot, v, (sinrot * u));
} else {
tmp = t_1;
}
return tmp;
}
function code(u, v, cosrot, sinrot, u0) t_0 = Float64(Float64(u - u0) * sinrot) t_1 = Float64(sinrot * Float64(u - u0)) tmp = 0.0 if (t_0 <= -1e+142) tmp = t_1; elseif (t_0 <= 5e+46) tmp = fma(cosrot, v, Float64(sinrot * u)); else tmp = t_1; end return tmp end
code[u_, v_, cosrot_, sinrot_, u0_] := Block[{t$95$0 = N[(N[(u - u0), $MachinePrecision] * sinrot), $MachinePrecision]}, Block[{t$95$1 = N[(sinrot * N[(u - u0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+142], t$95$1, If[LessEqual[t$95$0, 5e+46], N[(cosrot * v + N[(sinrot * u), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = LET t_0 = ((u - u0) * sinrot) IN LET t_1 = (sinrot * (u - u0)) IN LET tmp_1 = IF (t_0 <= (50000000000000002192292152253809867731702382592)) THEN ((cosrot * v) + (sinrot * u)) ELSE t_1 ENDIF IN LET tmp = IF (t_0 <= (-10000000000000000508222848402996879704791089448509839788449208028871961714412352270078388372553960191290960287445781834331294577148468377157632)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := \left(u - u0\right) \cdot sinrot\\
t_1 := sinrot \cdot \left(u - u0\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+142}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(cosrot, v, sinrot \cdot u\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 (-.f64 u u0) sinrot) < -1.0000000000000001e142 or 5.0000000000000002e46 < (*.f64 (-.f64 u u0) sinrot) Initial program 98.8%
Taylor expanded in v around 0
Applied rewrites62.1%
if -1.0000000000000001e142 < (*.f64 (-.f64 u u0) sinrot) < 5.0000000000000002e46Initial program 98.8%
Taylor expanded in u0 around 0
Applied rewrites70.8%
(FPCore (u v cosrot sinrot u0) :precision binary64 :pre TRUE (if (<= (* v cosrot) -5000000.0) (* cosrot v) (if (<= (* v cosrot) 2e+131) (* sinrot (- u u0)) (* cosrot v))))
double code(double u, double v, double cosrot, double sinrot, double u0) {
double tmp;
if ((v * cosrot) <= -5000000.0) {
tmp = cosrot * v;
} else if ((v * cosrot) <= 2e+131) {
tmp = sinrot * (u - u0);
} else {
tmp = cosrot * v;
}
return tmp;
}
real(8) function code(u, v, cosrot, sinrot, u0)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: cosrot
real(8), intent (in) :: sinrot
real(8), intent (in) :: u0
real(8) :: tmp
if ((v * cosrot) <= (-5000000.0d0)) then
tmp = cosrot * v
else if ((v * cosrot) <= 2d+131) then
tmp = sinrot * (u - u0)
else
tmp = cosrot * v
end if
code = tmp
end function
public static double code(double u, double v, double cosrot, double sinrot, double u0) {
double tmp;
if ((v * cosrot) <= -5000000.0) {
tmp = cosrot * v;
} else if ((v * cosrot) <= 2e+131) {
tmp = sinrot * (u - u0);
} else {
tmp = cosrot * v;
}
return tmp;
}
def code(u, v, cosrot, sinrot, u0): tmp = 0 if (v * cosrot) <= -5000000.0: tmp = cosrot * v elif (v * cosrot) <= 2e+131: tmp = sinrot * (u - u0) else: tmp = cosrot * v return tmp
function code(u, v, cosrot, sinrot, u0) tmp = 0.0 if (Float64(v * cosrot) <= -5000000.0) tmp = Float64(cosrot * v); elseif (Float64(v * cosrot) <= 2e+131) tmp = Float64(sinrot * Float64(u - u0)); else tmp = Float64(cosrot * v); end return tmp end
function tmp_2 = code(u, v, cosrot, sinrot, u0) tmp = 0.0; if ((v * cosrot) <= -5000000.0) tmp = cosrot * v; elseif ((v * cosrot) <= 2e+131) tmp = sinrot * (u - u0); else tmp = cosrot * v; end tmp_2 = tmp; end
code[u_, v_, cosrot_, sinrot_, u0_] := If[LessEqual[N[(v * cosrot), $MachinePrecision], -5000000.0], N[(cosrot * v), $MachinePrecision], If[LessEqual[N[(v * cosrot), $MachinePrecision], 2e+131], N[(sinrot * N[(u - u0), $MachinePrecision]), $MachinePrecision], N[(cosrot * v), $MachinePrecision]]]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = LET tmp_1 = IF ((v * cosrot) <= (199999999999999982405111001914463627825705729939051460364922737117355163153802565541919878198424069508213948681199740222346696327168)) THEN (sinrot * (u - u0)) ELSE (cosrot * v) ENDIF IN LET tmp = IF ((v * cosrot) <= (-5e6)) THEN (cosrot * v) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;v \cdot cosrot \leq -5000000:\\
\;\;\;\;cosrot \cdot v\\
\mathbf{elif}\;v \cdot cosrot \leq 2 \cdot 10^{+131}:\\
\;\;\;\;sinrot \cdot \left(u - u0\right)\\
\mathbf{else}:\\
\;\;\;\;cosrot \cdot v\\
\end{array}
if (*.f64 v cosrot) < -5e6 or 1.9999999999999998e131 < (*.f64 v cosrot) Initial program 98.8%
Taylor expanded in u0 around 0
Applied rewrites70.8%
Taylor expanded in u around 0
Applied rewrites41.4%
if -5e6 < (*.f64 v cosrot) < 1.9999999999999998e131Initial program 98.8%
Taylor expanded in v around 0
Applied rewrites62.1%
(FPCore (u v cosrot sinrot u0) :precision binary64 :pre TRUE (if (<= (* v cosrot) -5000000.0) (* cosrot v) (if (<= (* v cosrot) 1e+106) (* sinrot u) (* cosrot v))))
double code(double u, double v, double cosrot, double sinrot, double u0) {
double tmp;
if ((v * cosrot) <= -5000000.0) {
tmp = cosrot * v;
} else if ((v * cosrot) <= 1e+106) {
tmp = sinrot * u;
} else {
tmp = cosrot * v;
}
return tmp;
}
real(8) function code(u, v, cosrot, sinrot, u0)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: cosrot
real(8), intent (in) :: sinrot
real(8), intent (in) :: u0
real(8) :: tmp
if ((v * cosrot) <= (-5000000.0d0)) then
tmp = cosrot * v
else if ((v * cosrot) <= 1d+106) then
tmp = sinrot * u
else
tmp = cosrot * v
end if
code = tmp
end function
public static double code(double u, double v, double cosrot, double sinrot, double u0) {
double tmp;
if ((v * cosrot) <= -5000000.0) {
tmp = cosrot * v;
} else if ((v * cosrot) <= 1e+106) {
tmp = sinrot * u;
} else {
tmp = cosrot * v;
}
return tmp;
}
def code(u, v, cosrot, sinrot, u0): tmp = 0 if (v * cosrot) <= -5000000.0: tmp = cosrot * v elif (v * cosrot) <= 1e+106: tmp = sinrot * u else: tmp = cosrot * v return tmp
function code(u, v, cosrot, sinrot, u0) tmp = 0.0 if (Float64(v * cosrot) <= -5000000.0) tmp = Float64(cosrot * v); elseif (Float64(v * cosrot) <= 1e+106) tmp = Float64(sinrot * u); else tmp = Float64(cosrot * v); end return tmp end
function tmp_2 = code(u, v, cosrot, sinrot, u0) tmp = 0.0; if ((v * cosrot) <= -5000000.0) tmp = cosrot * v; elseif ((v * cosrot) <= 1e+106) tmp = sinrot * u; else tmp = cosrot * v; end tmp_2 = tmp; end
code[u_, v_, cosrot_, sinrot_, u0_] := If[LessEqual[N[(v * cosrot), $MachinePrecision], -5000000.0], N[(cosrot * v), $MachinePrecision], If[LessEqual[N[(v * cosrot), $MachinePrecision], 1e+106], N[(sinrot * u), $MachinePrecision], N[(cosrot * v), $MachinePrecision]]]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = LET tmp_1 = IF ((v * cosrot) <= (10000000000000000910359990503684350104604539951754865571545457374840902895351334152154180097541612190564352)) THEN (sinrot * u) ELSE (cosrot * v) ENDIF IN LET tmp = IF ((v * cosrot) <= (-5e6)) THEN (cosrot * v) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;v \cdot cosrot \leq -5000000:\\
\;\;\;\;cosrot \cdot v\\
\mathbf{elif}\;v \cdot cosrot \leq 10^{+106}:\\
\;\;\;\;sinrot \cdot u\\
\mathbf{else}:\\
\;\;\;\;cosrot \cdot v\\
\end{array}
if (*.f64 v cosrot) < -5e6 or 1.0000000000000001e106 < (*.f64 v cosrot) Initial program 98.8%
Taylor expanded in u0 around 0
Applied rewrites70.8%
Taylor expanded in u around 0
Applied rewrites41.4%
if -5e6 < (*.f64 v cosrot) < 1.0000000000000001e106Initial program 98.8%
Taylor expanded in u0 around 0
Applied rewrites70.8%
Taylor expanded in u around 0
Applied rewrites41.4%
Taylor expanded in undef-var around zero
Applied rewrites3.0%
Taylor expanded in u around inf
Applied rewrites33.1%
(FPCore (u v cosrot sinrot u0) :precision binary64 :pre TRUE (* cosrot v))
double code(double u, double v, double cosrot, double sinrot, double u0) {
return cosrot * v;
}
real(8) function code(u, v, cosrot, sinrot, u0)
use fmin_fmax_functions
real(8), intent (in) :: u
real(8), intent (in) :: v
real(8), intent (in) :: cosrot
real(8), intent (in) :: sinrot
real(8), intent (in) :: u0
code = cosrot * v
end function
public static double code(double u, double v, double cosrot, double sinrot, double u0) {
return cosrot * v;
}
def code(u, v, cosrot, sinrot, u0): return cosrot * v
function code(u, v, cosrot, sinrot, u0) return Float64(cosrot * v) end
function tmp = code(u, v, cosrot, sinrot, u0) tmp = cosrot * v; end
code[u_, v_, cosrot_, sinrot_, u0_] := N[(cosrot * v), $MachinePrecision]
f(u, v, cosrot, sinrot, u0): u in [-inf, +inf], v in [-inf, +inf], cosrot in [-inf, +inf], sinrot in [-inf, +inf], u0 in [-inf, +inf] code: THEORY BEGIN f(u, v, cosrot, sinrot, u0: real): real = cosrot * v END code
cosrot \cdot v
Initial program 98.8%
Taylor expanded in u0 around 0
Applied rewrites70.8%
Taylor expanded in u around 0
Applied rewrites41.4%
herbie shell --seed 2026050 +o generate:egglog
(FPCore (u v cosrot sinrot u0)
:name "forward-rot-x"
:precision binary64
(+ (* v cosrot) (* (- u u0) sinrot)))