
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)))
(-
(* t_3 t_3)
(*
(*
4.0
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b angle x-scale y-scale)
:precision binary64
(let* ((t_0 (* (/ angle 180.0) (PI)))
(t_1 (sin t_0))
(t_2 (cos t_0))
(t_3
(/
(/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) t_1) t_2) x-scale)
y-scale)))
(-
(* t_3 t_3)
(*
(*
4.0
(/ (/ (+ (pow (* a t_1) 2.0) (pow (* b t_2) 2.0)) x-scale) x-scale))
(/ (/ (+ (pow (* a t_2) 2.0) (pow (* b t_1) 2.0)) y-scale) y-scale)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \mathsf{PI}\left(\right)\\
t_1 := \sin t\_0\\
t_2 := \cos t\_0\\
t_3 := \frac{\frac{\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot t\_1\right) \cdot t\_2}{x-scale}}{y-scale}\\
t\_3 \cdot t\_3 - \left(4 \cdot \frac{\frac{{\left(a \cdot t\_1\right)}^{2} + {\left(b \cdot t\_2\right)}^{2}}{x-scale}}{x-scale}\right) \cdot \frac{\frac{{\left(a \cdot t\_2\right)}^{2} + {\left(b \cdot t\_1\right)}^{2}}{y-scale}}{y-scale}
\end{array}
\end{array}
x-scale_m = (fabs.f64 x-scale)
(FPCore (a b angle x-scale_m y-scale)
:precision binary64
(if (<= x-scale_m 8.5e+157)
(*
(/ (* a b) y-scale)
(/ (/ (* -4.0 (/ (* a b) x-scale_m)) y-scale) x-scale_m))
(* (* (* (pow (/ b (* y-scale x-scale_m)) 2.0) -4.0) a) a)))x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double tmp;
if (x_45_scale_m <= 8.5e+157) {
tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m);
} else {
tmp = ((pow((b / (y_45_scale * x_45_scale_m)), 2.0) * -4.0) * a) * a;
}
return tmp;
}
x-scale_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
real(8) :: tmp
if (x_45scale_m <= 8.5d+157) then
tmp = ((a * b) / y_45scale) * ((((-4.0d0) * ((a * b) / x_45scale_m)) / y_45scale) / x_45scale_m)
else
tmp = ((((b / (y_45scale * x_45scale_m)) ** 2.0d0) * (-4.0d0)) * a) * a
end if
code = tmp
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double tmp;
if (x_45_scale_m <= 8.5e+157) {
tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m);
} else {
tmp = ((Math.pow((b / (y_45_scale * x_45_scale_m)), 2.0) * -4.0) * a) * a;
}
return tmp;
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): tmp = 0 if x_45_scale_m <= 8.5e+157: tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m) else: tmp = ((math.pow((b / (y_45_scale * x_45_scale_m)), 2.0) * -4.0) * a) * a return tmp
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) tmp = 0.0 if (x_45_scale_m <= 8.5e+157) tmp = Float64(Float64(Float64(a * b) / y_45_scale) * Float64(Float64(Float64(-4.0 * Float64(Float64(a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m)); else tmp = Float64(Float64(Float64((Float64(b / Float64(y_45_scale * x_45_scale_m)) ^ 2.0) * -4.0) * a) * a); end return tmp end
x-scale_m = abs(x_45_scale); function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = 0.0; if (x_45_scale_m <= 8.5e+157) tmp = ((a * b) / y_45_scale) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / x_45_scale_m); else tmp = ((((b / (y_45_scale * x_45_scale_m)) ^ 2.0) * -4.0) * a) * a; end tmp_2 = tmp; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := If[LessEqual[x$45$scale$95$m, 8.5e+157], N[(N[(N[(a * b), $MachinePrecision] / y$45$scale), $MachinePrecision] * N[(N[(N[(-4.0 * N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[N[(b / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -4.0), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
\mathbf{if}\;x-scale\_m \leq 8.5 \cdot 10^{+157}:\\
\;\;\;\;\frac{a \cdot b}{y-scale} \cdot \frac{\frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{y-scale}}{x-scale\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\left({\left(\frac{b}{y-scale \cdot x-scale\_m}\right)}^{2} \cdot -4\right) \cdot a\right) \cdot a\\
\end{array}
\end{array}
if x-scale < 8.4999999999999998e157Initial program 19.3%
Taylor expanded in angle around 0
Applied rewrites53.3%
Applied rewrites80.4%
Applied rewrites84.8%
Applied rewrites91.4%
if 8.4999999999999998e157 < x-scale Initial program 46.9%
Taylor expanded in a around 0
Applied rewrites56.5%
Taylor expanded in angle around 0
Applied rewrites46.5%
Applied rewrites68.3%
Applied rewrites90.3%
x-scale_m = (fabs.f64 x-scale)
(FPCore (a b angle x-scale_m y-scale)
:precision binary64
(let* ((t_0 (/ (* a b) x-scale_m)))
(if (<= y-scale 1.4e-228)
(/
(* (* (/ (/ -4.0 y-scale) x-scale_m) (* a b)) (* a b))
(* y-scale x-scale_m))
(* t_0 (/ (/ (* -4.0 t_0) y-scale) y-scale)))))x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = (a * b) / x_45_scale_m;
double tmp;
if (y_45_scale <= 1.4e-228) {
tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m);
} else {
tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale);
}
return tmp;
}
x-scale_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
real(8) :: t_0
real(8) :: tmp
t_0 = (a * b) / x_45scale_m
if (y_45scale <= 1.4d-228) then
tmp = (((((-4.0d0) / y_45scale) / x_45scale_m) * (a * b)) * (a * b)) / (y_45scale * x_45scale_m)
else
tmp = t_0 * ((((-4.0d0) * t_0) / y_45scale) / y_45scale)
end if
code = tmp
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = (a * b) / x_45_scale_m;
double tmp;
if (y_45_scale <= 1.4e-228) {
tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m);
} else {
tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale);
}
return tmp;
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): t_0 = (a * b) / x_45_scale_m tmp = 0 if y_45_scale <= 1.4e-228: tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m) else: tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale) return tmp
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = Float64(Float64(a * b) / x_45_scale_m) tmp = 0.0 if (y_45_scale <= 1.4e-228) tmp = Float64(Float64(Float64(Float64(Float64(-4.0 / y_45_scale) / x_45_scale_m) * Float64(a * b)) * Float64(a * b)) / Float64(y_45_scale * x_45_scale_m)); else tmp = Float64(t_0 * Float64(Float64(Float64(-4.0 * t_0) / y_45_scale) / y_45_scale)); end return tmp end
x-scale_m = abs(x_45_scale); function tmp_2 = code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = (a * b) / x_45_scale_m; tmp = 0.0; if (y_45_scale <= 1.4e-228) tmp = ((((-4.0 / y_45_scale) / x_45_scale_m) * (a * b)) * (a * b)) / (y_45_scale * x_45_scale_m); else tmp = t_0 * (((-4.0 * t_0) / y_45_scale) / y_45_scale); end tmp_2 = tmp; end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := Block[{t$95$0 = N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]}, If[LessEqual[y$45$scale, 1.4e-228], N[(N[(N[(N[(N[(-4.0 / y$45$scale), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision] / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-4.0 * t$95$0), $MachinePrecision] / y$45$scale), $MachinePrecision] / y$45$scale), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
t_0 := \frac{a \cdot b}{x-scale\_m}\\
\mathbf{if}\;y-scale \leq 1.4 \cdot 10^{-228}:\\
\;\;\;\;\frac{\left(\frac{\frac{-4}{y-scale}}{x-scale\_m} \cdot \left(a \cdot b\right)\right) \cdot \left(a \cdot b\right)}{y-scale \cdot x-scale\_m}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{-4 \cdot t\_0}{y-scale}}{y-scale}\\
\end{array}
\end{array}
if y-scale < 1.4000000000000001e-228Initial program 18.5%
Taylor expanded in angle around 0
Applied rewrites50.2%
Applied rewrites76.8%
Applied rewrites82.5%
Applied rewrites87.7%
if 1.4000000000000001e-228 < y-scale Initial program 29.9%
Taylor expanded in angle around 0
Applied rewrites58.9%
Applied rewrites83.1%
Applied rewrites86.8%
Applied rewrites95.3%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* (* a b) (/ (/ (* -4.0 (/ (* a b) x-scale_m)) y-scale) (* y-scale x-scale_m))))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m));
}
x-scale_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
code = (a * b) * ((((-4.0d0) * ((a * b) / x_45scale_m)) / y_45scale) / (y_45scale * x_45scale_m))
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m));
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): return (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m))
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(Float64(a * b) * Float64(Float64(Float64(-4.0 * Float64(Float64(a * b) / x_45_scale_m)) / y_45_scale) / Float64(y_45_scale * x_45_scale_m))) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = (a * b) * (((-4.0 * ((a * b) / x_45_scale_m)) / y_45_scale) / (y_45_scale * x_45_scale_m)); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(a * b), $MachinePrecision] * N[(N[(N[(-4.0 * N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] / y$45$scale), $MachinePrecision] / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\left(a \cdot b\right) \cdot \frac{\frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{y-scale}}{y-scale \cdot x-scale\_m}
\end{array}
Initial program 23.7%
Taylor expanded in angle around 0
Applied rewrites54.2%
Applied rewrites79.7%
Applied rewrites84.5%
Applied rewrites88.9%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* (* a b) (/ (* -4.0 (/ (* a b) x-scale_m)) (* (* y-scale x-scale_m) y-scale))))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale));
}
x-scale_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
code = (a * b) * (((-4.0d0) * ((a * b) / x_45scale_m)) / ((y_45scale * x_45scale_m) * y_45scale))
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale));
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): return (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale))
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(Float64(a * b) * Float64(Float64(-4.0 * Float64(Float64(a * b) / x_45_scale_m)) / Float64(Float64(y_45_scale * x_45_scale_m) * y_45_scale))) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = (a * b) * ((-4.0 * ((a * b) / x_45_scale_m)) / ((y_45_scale * x_45_scale_m) * y_45_scale)); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(a * b), $MachinePrecision] * N[(N[(-4.0 * N[(N[(a * b), $MachinePrecision] / x$45$scale$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale$95$m), $MachinePrecision] * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\left(a \cdot b\right) \cdot \frac{-4 \cdot \frac{a \cdot b}{x-scale\_m}}{\left(y-scale \cdot x-scale\_m\right) \cdot y-scale}
\end{array}
Initial program 23.7%
Taylor expanded in angle around 0
Applied rewrites54.2%
Applied rewrites79.7%
Applied rewrites84.5%
Applied rewrites83.5%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (let* ((t_0 (/ b (* y-scale x-scale_m)))) (* (* -4.0 (* t_0 t_0)) (* a a))))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = b / (y_45_scale * x_45_scale_m);
return (-4.0 * (t_0 * t_0)) * (a * a);
}
x-scale_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
real(8) :: t_0
t_0 = b / (y_45scale * x_45scale_m)
code = ((-4.0d0) * (t_0 * t_0)) * (a * a)
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
double t_0 = b / (y_45_scale * x_45_scale_m);
return (-4.0 * (t_0 * t_0)) * (a * a);
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): t_0 = b / (y_45_scale * x_45_scale_m) return (-4.0 * (t_0 * t_0)) * (a * a)
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = Float64(b / Float64(y_45_scale * x_45_scale_m)) return Float64(Float64(-4.0 * Float64(t_0 * t_0)) * Float64(a * a)) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) t_0 = b / (y_45_scale * x_45_scale_m); tmp = (-4.0 * (t_0 * t_0)) * (a * a); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision]
code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := Block[{t$95$0 = N[(b / N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(-4.0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\begin{array}{l}
t_0 := \frac{b}{y-scale \cdot x-scale\_m}\\
\left(-4 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \left(a \cdot a\right)
\end{array}
\end{array}
Initial program 23.7%
Taylor expanded in a around 0
Applied rewrites47.4%
Taylor expanded in angle around 0
Applied rewrites47.3%
Applied rewrites73.7%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* (* -4.0 (/ (* b b) (* (* y-scale x-scale_m) (* y-scale x-scale_m)))) (* a a)))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a);
}
x-scale_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
code = ((-4.0d0) * ((b * b) / ((y_45scale * x_45scale_m) * (y_45scale * x_45scale_m)))) * (a * a)
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a);
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): return (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a)
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(Float64(-4.0 * Float64(Float64(b * b) / Float64(Float64(y_45_scale * x_45_scale_m) * Float64(y_45_scale * x_45_scale_m)))) * Float64(a * a)) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = (-4.0 * ((b * b) / ((y_45_scale * x_45_scale_m) * (y_45_scale * x_45_scale_m)))) * (a * a); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(-4.0 * N[(N[(b * b), $MachinePrecision] / N[(N[(y$45$scale * x$45$scale$95$m), $MachinePrecision] * N[(y$45$scale * x$45$scale$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\left(-4 \cdot \frac{b \cdot b}{\left(y-scale \cdot x-scale\_m\right) \cdot \left(y-scale \cdot x-scale\_m\right)}\right) \cdot \left(a \cdot a\right)
\end{array}
Initial program 23.7%
Taylor expanded in a around 0
Applied rewrites47.4%
Taylor expanded in angle around 0
Applied rewrites47.3%
Applied rewrites60.7%
x-scale_m = (fabs.f64 x-scale) (FPCore (a b angle x-scale_m y-scale) :precision binary64 (* (* -4.0 (/ (* b b) (* (* x-scale_m x-scale_m) (* y-scale y-scale)))) (* a a)))
x-scale_m = fabs(x_45_scale);
double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a);
}
x-scale_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, angle, x_45scale_m, y_45scale)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
real(8), intent (in) :: x_45scale_m
real(8), intent (in) :: y_45scale
code = ((-4.0d0) * ((b * b) / ((x_45scale_m * x_45scale_m) * (y_45scale * y_45scale)))) * (a * a)
end function
x-scale_m = Math.abs(x_45_scale);
public static double code(double a, double b, double angle, double x_45_scale_m, double y_45_scale) {
return (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a);
}
x-scale_m = math.fabs(x_45_scale) def code(a, b, angle, x_45_scale_m, y_45_scale): return (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a)
x-scale_m = abs(x_45_scale) function code(a, b, angle, x_45_scale_m, y_45_scale) return Float64(Float64(-4.0 * Float64(Float64(b * b) / Float64(Float64(x_45_scale_m * x_45_scale_m) * Float64(y_45_scale * y_45_scale)))) * Float64(a * a)) end
x-scale_m = abs(x_45_scale); function tmp = code(a, b, angle, x_45_scale_m, y_45_scale) tmp = (-4.0 * ((b * b) / ((x_45_scale_m * x_45_scale_m) * (y_45_scale * y_45_scale)))) * (a * a); end
x-scale_m = N[Abs[x$45$scale], $MachinePrecision] code[a_, b_, angle_, x$45$scale$95$m_, y$45$scale_] := N[(N[(-4.0 * N[(N[(b * b), $MachinePrecision] / N[(N[(x$45$scale$95$m * x$45$scale$95$m), $MachinePrecision] * N[(y$45$scale * y$45$scale), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x-scale_m = \left|x-scale\right|
\\
\left(-4 \cdot \frac{b \cdot b}{\left(x-scale\_m \cdot x-scale\_m\right) \cdot \left(y-scale \cdot y-scale\right)}\right) \cdot \left(a \cdot a\right)
\end{array}
Initial program 23.7%
Taylor expanded in a around 0
Applied rewrites47.4%
Taylor expanded in angle around 0
Applied rewrites47.3%
herbie shell --seed 2025018
(FPCore (a b angle x-scale y-scale)
:name "Simplification of discriminant from scale-rotated-ellipse"
:precision binary64
(- (* (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) (PI)))) (cos (* (/ angle 180.0) (PI)))) x-scale) y-scale) (/ (/ (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* (/ angle 180.0) (PI)))) (cos (* (/ angle 180.0) (PI)))) x-scale) y-scale)) (* (* 4.0 (/ (/ (+ (pow (* a (sin (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (cos (* (/ angle 180.0) (PI)))) 2.0)) x-scale) x-scale)) (/ (/ (+ (pow (* a (cos (* (/ angle 180.0) (PI)))) 2.0) (pow (* b (sin (* (/ angle 180.0) (PI)))) 2.0)) y-scale) y-scale))))