
(FPCore (z0 z1 z3 z2) :precision binary64 (acos (+ (* (sin z0) (sin z1)) (* (* (cos (- z3 z2)) (cos z1)) (cos z0)))))
double code(double z0, double z1, double z3, double z2) {
return acos(((sin(z0) * sin(z1)) + ((cos((z3 - z2)) * cos(z1)) * cos(z0))));
}
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(z0, z1, z3, z2)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8), intent (in) :: z2
code = acos(((sin(z0) * sin(z1)) + ((cos((z3 - z2)) * cos(z1)) * cos(z0))))
end function
public static double code(double z0, double z1, double z3, double z2) {
return Math.acos(((Math.sin(z0) * Math.sin(z1)) + ((Math.cos((z3 - z2)) * Math.cos(z1)) * Math.cos(z0))));
}
def code(z0, z1, z3, z2): return math.acos(((math.sin(z0) * math.sin(z1)) + ((math.cos((z3 - z2)) * math.cos(z1)) * math.cos(z0))))
function code(z0, z1, z3, z2) return acos(Float64(Float64(sin(z0) * sin(z1)) + Float64(Float64(cos(Float64(z3 - z2)) * cos(z1)) * cos(z0)))) end
function tmp = code(z0, z1, z3, z2) tmp = acos(((sin(z0) * sin(z1)) + ((cos((z3 - z2)) * cos(z1)) * cos(z0)))); end
code[z0_, z1_, z3_, z2_] := N[ArcCos[N[(N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision] * N[Cos[z1], $MachinePrecision]), $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\sin z0 \cdot \sin z1 + \left(\cos \left(z3 - z2\right) \cdot \cos z1\right) \cdot \cos z0\right)
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0 z1 z3 z2) :precision binary64 (acos (+ (* (sin z0) (sin z1)) (* (* (cos (- z3 z2)) (cos z1)) (cos z0)))))
double code(double z0, double z1, double z3, double z2) {
return acos(((sin(z0) * sin(z1)) + ((cos((z3 - z2)) * cos(z1)) * cos(z0))));
}
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(z0, z1, z3, z2)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8), intent (in) :: z2
code = acos(((sin(z0) * sin(z1)) + ((cos((z3 - z2)) * cos(z1)) * cos(z0))))
end function
public static double code(double z0, double z1, double z3, double z2) {
return Math.acos(((Math.sin(z0) * Math.sin(z1)) + ((Math.cos((z3 - z2)) * Math.cos(z1)) * Math.cos(z0))));
}
def code(z0, z1, z3, z2): return math.acos(((math.sin(z0) * math.sin(z1)) + ((math.cos((z3 - z2)) * math.cos(z1)) * math.cos(z0))))
function code(z0, z1, z3, z2) return acos(Float64(Float64(sin(z0) * sin(z1)) + Float64(Float64(cos(Float64(z3 - z2)) * cos(z1)) * cos(z0)))) end
function tmp = code(z0, z1, z3, z2) tmp = acos(((sin(z0) * sin(z1)) + ((cos((z3 - z2)) * cos(z1)) * cos(z0)))); end
code[z0_, z1_, z3_, z2_] := N[ArcCos[N[(N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision] * N[Cos[z1], $MachinePrecision]), $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\sin z0 \cdot \sin z1 + \left(\cos \left(z3 - z2\right) \cdot \cos z1\right) \cdot \cos z0\right)
(FPCore (z0 z1 z3 z2)
:precision binary64
(let* ((t_0 (* (cos z2) (cos z3))))
(acos
(+
(* (sin z0) (sin z1))
(*
(* (* (+ 1 (/ (* (sin z2) (sin z3)) t_0)) t_0) (cos z1))
(cos z0))))))double code(double z0, double z1, double z3, double z2) {
double t_0 = cos(z2) * cos(z3);
return acos(((sin(z0) * sin(z1)) + ((((1.0 + ((sin(z2) * sin(z3)) / t_0)) * t_0) * cos(z1)) * cos(z0))));
}
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(z0, z1, z3, z2)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8), intent (in) :: z2
real(8) :: t_0
t_0 = cos(z2) * cos(z3)
code = acos(((sin(z0) * sin(z1)) + ((((1.0d0 + ((sin(z2) * sin(z3)) / t_0)) * t_0) * cos(z1)) * cos(z0))))
end function
public static double code(double z0, double z1, double z3, double z2) {
double t_0 = Math.cos(z2) * Math.cos(z3);
return Math.acos(((Math.sin(z0) * Math.sin(z1)) + ((((1.0 + ((Math.sin(z2) * Math.sin(z3)) / t_0)) * t_0) * Math.cos(z1)) * Math.cos(z0))));
}
def code(z0, z1, z3, z2): t_0 = math.cos(z2) * math.cos(z3) return math.acos(((math.sin(z0) * math.sin(z1)) + ((((1.0 + ((math.sin(z2) * math.sin(z3)) / t_0)) * t_0) * math.cos(z1)) * math.cos(z0))))
function code(z0, z1, z3, z2) t_0 = Float64(cos(z2) * cos(z3)) return acos(Float64(Float64(sin(z0) * sin(z1)) + Float64(Float64(Float64(Float64(1.0 + Float64(Float64(sin(z2) * sin(z3)) / t_0)) * t_0) * cos(z1)) * cos(z0)))) end
function tmp = code(z0, z1, z3, z2) t_0 = cos(z2) * cos(z3); tmp = acos(((sin(z0) * sin(z1)) + ((((1.0 + ((sin(z2) * sin(z3)) / t_0)) * t_0) * cos(z1)) * cos(z0)))); end
code[z0_, z1_, z3_, z2_] := Block[{t$95$0 = N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]}, N[ArcCos[N[(N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(1 + N[(N[(N[Sin[z2], $MachinePrecision] * N[Sin[z3], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Cos[z1], $MachinePrecision]), $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \cos z2 \cdot \cos z3\\
\cos^{-1} \left(\sin z0 \cdot \sin z1 + \left(\left(\left(1 + \frac{\sin z2 \cdot \sin z3}{t\_0}\right) \cdot t\_0\right) \cdot \cos z1\right) \cdot \cos z0\right)
\end{array}
Initial program 73.9%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6493.7%
Applied rewrites93.7%
(FPCore (z0 z1 z3 z2) :precision binary64 (acos (+ (* (sin z0) (sin z1)) (* (* (* (- (* (tan z3) (tan z2)) -1) (* (cos z3) (cos z2))) (cos z1)) (cos z0)))))
double code(double z0, double z1, double z3, double z2) {
return acos(((sin(z0) * sin(z1)) + (((((tan(z3) * tan(z2)) - -1.0) * (cos(z3) * cos(z2))) * cos(z1)) * cos(z0))));
}
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(z0, z1, z3, z2)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8), intent (in) :: z2
code = acos(((sin(z0) * sin(z1)) + (((((tan(z3) * tan(z2)) - (-1.0d0)) * (cos(z3) * cos(z2))) * cos(z1)) * cos(z0))))
end function
public static double code(double z0, double z1, double z3, double z2) {
return Math.acos(((Math.sin(z0) * Math.sin(z1)) + (((((Math.tan(z3) * Math.tan(z2)) - -1.0) * (Math.cos(z3) * Math.cos(z2))) * Math.cos(z1)) * Math.cos(z0))));
}
def code(z0, z1, z3, z2): return math.acos(((math.sin(z0) * math.sin(z1)) + (((((math.tan(z3) * math.tan(z2)) - -1.0) * (math.cos(z3) * math.cos(z2))) * math.cos(z1)) * math.cos(z0))))
function code(z0, z1, z3, z2) return acos(Float64(Float64(sin(z0) * sin(z1)) + Float64(Float64(Float64(Float64(Float64(tan(z3) * tan(z2)) - -1.0) * Float64(cos(z3) * cos(z2))) * cos(z1)) * cos(z0)))) end
function tmp = code(z0, z1, z3, z2) tmp = acos(((sin(z0) * sin(z1)) + (((((tan(z3) * tan(z2)) - -1.0) * (cos(z3) * cos(z2))) * cos(z1)) * cos(z0)))); end
code[z0_, z1_, z3_, z2_] := N[ArcCos[N[(N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(N[Tan[z3], $MachinePrecision] * N[Tan[z2], $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision] * N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[z1], $MachinePrecision]), $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\sin z0 \cdot \sin z1 + \left(\left(\left(\tan z3 \cdot \tan z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right) \cdot \cos z1\right) \cdot \cos z0\right)
Initial program 73.9%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6493.7%
Applied rewrites93.7%
Applied rewrites93.7%
(FPCore (z0 z1 z3 z2) :precision binary64 (acos (+ (* (sin z0) (sin z1)) (* (* (+ (* (sin z2) (sin z3)) (* (cos z2) (cos z3))) (cos z1)) (cos z0)))))
double code(double z0, double z1, double z3, double z2) {
return acos(((sin(z0) * sin(z1)) + ((((sin(z2) * sin(z3)) + (cos(z2) * cos(z3))) * cos(z1)) * cos(z0))));
}
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(z0, z1, z3, z2)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8), intent (in) :: z2
code = acos(((sin(z0) * sin(z1)) + ((((sin(z2) * sin(z3)) + (cos(z2) * cos(z3))) * cos(z1)) * cos(z0))))
end function
public static double code(double z0, double z1, double z3, double z2) {
return Math.acos(((Math.sin(z0) * Math.sin(z1)) + ((((Math.sin(z2) * Math.sin(z3)) + (Math.cos(z2) * Math.cos(z3))) * Math.cos(z1)) * Math.cos(z0))));
}
def code(z0, z1, z3, z2): return math.acos(((math.sin(z0) * math.sin(z1)) + ((((math.sin(z2) * math.sin(z3)) + (math.cos(z2) * math.cos(z3))) * math.cos(z1)) * math.cos(z0))))
function code(z0, z1, z3, z2) return acos(Float64(Float64(sin(z0) * sin(z1)) + Float64(Float64(Float64(Float64(sin(z2) * sin(z3)) + Float64(cos(z2) * cos(z3))) * cos(z1)) * cos(z0)))) end
function tmp = code(z0, z1, z3, z2) tmp = acos(((sin(z0) * sin(z1)) + ((((sin(z2) * sin(z3)) + (cos(z2) * cos(z3))) * cos(z1)) * cos(z0)))); end
code[z0_, z1_, z3_, z2_] := N[ArcCos[N[(N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[Sin[z2], $MachinePrecision] * N[Sin[z3], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[z1], $MachinePrecision]), $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\sin z0 \cdot \sin z1 + \left(\left(\sin z2 \cdot \sin z3 + \cos z2 \cdot \cos z3\right) \cdot \cos z1\right) \cdot \cos z0\right)
Initial program 73.9%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6493.7%
Applied rewrites93.7%
(FPCore (z0 z1 z3 z2)
:precision binary64
(-
(* PI 1/2)
(-
(* PI 1/2)
(acos
(+
(* (* (cos (- z3 z2)) (cos z1)) (cos z0))
(* (sin z1) (sin z0)))))))double code(double z0, double z1, double z3, double z2) {
return (((double) M_PI) * 0.5) - ((((double) M_PI) * 0.5) - acos((((cos((z3 - z2)) * cos(z1)) * cos(z0)) + (sin(z1) * sin(z0)))));
}
public static double code(double z0, double z1, double z3, double z2) {
return (Math.PI * 0.5) - ((Math.PI * 0.5) - Math.acos((((Math.cos((z3 - z2)) * Math.cos(z1)) * Math.cos(z0)) + (Math.sin(z1) * Math.sin(z0)))));
}
def code(z0, z1, z3, z2): return (math.pi * 0.5) - ((math.pi * 0.5) - math.acos((((math.cos((z3 - z2)) * math.cos(z1)) * math.cos(z0)) + (math.sin(z1) * math.sin(z0)))))
function code(z0, z1, z3, z2) return Float64(Float64(pi * 0.5) - Float64(Float64(pi * 0.5) - acos(Float64(Float64(Float64(cos(Float64(z3 - z2)) * cos(z1)) * cos(z0)) + Float64(sin(z1) * sin(z0)))))) end
function tmp = code(z0, z1, z3, z2) tmp = (pi * 0.5) - ((pi * 0.5) - acos((((cos((z3 - z2)) * cos(z1)) * cos(z0)) + (sin(z1) * sin(z0))))); end
code[z0_, z1_, z3_, z2_] := N[(N[(Pi * 1/2), $MachinePrecision] - N[(N[(Pi * 1/2), $MachinePrecision] - N[ArcCos[N[(N[(N[(N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision] * N[Cos[z1], $MachinePrecision]), $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[z1], $MachinePrecision] * N[Sin[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\pi \cdot \frac{1}{2} - \left(\pi \cdot \frac{1}{2} - \cos^{-1} \left(\left(\cos \left(z3 - z2\right) \cdot \cos z1\right) \cdot \cos z0 + \sin z1 \cdot \sin z0\right)\right)
Initial program 73.9%
lift-acos.f64N/A
acos-asinN/A
lower--.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-PI.f64N/A
metadata-evalN/A
lower-asin.f6473.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6473.7%
Applied rewrites73.7%
Applied rewrites73.9%
(FPCore (z0 z1 z3 z2) :precision binary64 (acos (+ (* (sin z0) (sin z1)) (* (* (cos z0) (cos z1)) (cos (- z2 z3))))))
double code(double z0, double z1, double z3, double z2) {
return acos(((sin(z0) * sin(z1)) + ((cos(z0) * cos(z1)) * cos((z2 - z3)))));
}
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(z0, z1, z3, z2)
use fmin_fmax_functions
real(8), intent (in) :: z0
real(8), intent (in) :: z1
real(8), intent (in) :: z3
real(8), intent (in) :: z2
code = acos(((sin(z0) * sin(z1)) + ((cos(z0) * cos(z1)) * cos((z2 - z3)))))
end function
public static double code(double z0, double z1, double z3, double z2) {
return Math.acos(((Math.sin(z0) * Math.sin(z1)) + ((Math.cos(z0) * Math.cos(z1)) * Math.cos((z2 - z3)))));
}
def code(z0, z1, z3, z2): return math.acos(((math.sin(z0) * math.sin(z1)) + ((math.cos(z0) * math.cos(z1)) * math.cos((z2 - z3)))))
function code(z0, z1, z3, z2) return acos(Float64(Float64(sin(z0) * sin(z1)) + Float64(Float64(cos(z0) * cos(z1)) * cos(Float64(z2 - z3))))) end
function tmp = code(z0, z1, z3, z2) tmp = acos(((sin(z0) * sin(z1)) + ((cos(z0) * cos(z1)) * cos((z2 - z3))))); end
code[z0_, z1_, z3_, z2_] := N[ArcCos[N[(N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[z0], $MachinePrecision] * N[Cos[z1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\sin z0 \cdot \sin z1 + \left(\cos z0 \cdot \cos z1\right) \cdot \cos \left(z2 - z3\right)\right)
Initial program 73.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.9%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6473.9%
Applied rewrites73.9%
herbie shell --seed 2025277 -o generate:taylor -o generate:evaluate
(FPCore (z0 z1 z3 z2)
:name "(acos (+ (* (sin z0) (sin z1)) (* (* (cos (- z3 z2)) (cos z1)) (cos z0))))"
:precision binary64
(acos (+ (* (sin z0) (sin z1)) (* (* (cos (- z3 z2)) (cos z1)) (cos z0)))))