
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a) :precision binary64 (+ x (fma (+ (tan y) (tan z)) (/ 1.0 (- (- 1.0 (+ 2.0 (fma (tan y) (tan z) -1.0))) -1.0)) (- (tan a)))))
double code(double x, double y, double z, double a) {
return x + fma((tan(y) + tan(z)), (1.0 / ((1.0 - (2.0 + fma(tan(y), tan(z), -1.0))) - -1.0)), -tan(a));
}
function code(x, y, z, a) return Float64(x + fma(Float64(tan(y) + tan(z)), Float64(1.0 / Float64(Float64(1.0 - Float64(2.0 + fma(tan(y), tan(z), -1.0))) - -1.0)), Float64(-tan(a)))) end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[(1.0 - N[(2.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\tan y + \tan z, \frac{1}{\left(1 - \left(2 + \mathsf{fma}\left(\tan y, \tan z, -1\right)\right)\right) - -1}, -\tan a\right)
\end{array}
Initial program 77.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
expm1-log1p-u91.5%
expm1-undefine91.5%
log1p-undefine91.5%
add-exp-log99.7%
Applied egg-rr99.7%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
expm1-log1p-u91.5%
expm1-undefine91.5%
log1p-undefine91.5%
add-exp-log99.7%
Applied egg-rr99.7%
sub-neg99.7%
associate-+r+99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
div-inv99.7%
fma-neg99.7%
associate--r+99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (+ -1.0 (+ 2.0 (fma (tan y) (tan z) -1.0))))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - (-1.0 + (2.0 + fma(tan(y), tan(z), -1.0))))) - tan(a));
}
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(-1.0 + Float64(2.0 + fma(tan(y), tan(z), -1.0))))) - tan(a))) end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(-1.0 + N[(2.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \left(-1 + \left(2 + \mathsf{fma}\left(\tan y, \tan z, -1\right)\right)\right)} - \tan a\right)
\end{array}
Initial program 77.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
expm1-log1p-u91.5%
expm1-undefine91.5%
log1p-undefine91.5%
add-exp-log99.7%
Applied egg-rr99.7%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
expm1-log1p-u91.5%
expm1-undefine91.5%
log1p-undefine91.5%
add-exp-log99.7%
Applied egg-rr99.7%
sub-neg99.7%
associate-+r+99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (- x (+ (tan a) (/ (+ (tan y) (tan z)) (+ -1.0 (+ 1.0 (fma (tan y) (tan z) -1.0)))))))
double code(double x, double y, double z, double a) {
return x - (tan(a) + ((tan(y) + tan(z)) / (-1.0 + (1.0 + fma(tan(y), tan(z), -1.0)))));
}
function code(x, y, z, a) return Float64(x - Float64(tan(a) + Float64(Float64(tan(y) + tan(z)) / Float64(-1.0 + Float64(1.0 + fma(tan(y), tan(z), -1.0)))))) end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(1.0 + N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a + \frac{\tan y + \tan z}{-1 + \left(1 + \mathsf{fma}\left(\tan y, \tan z, -1\right)\right)}\right)
\end{array}
Initial program 77.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
expm1-log1p-u91.5%
expm1-undefine91.5%
log1p-undefine91.5%
add-exp-log99.7%
Applied egg-rr99.7%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 77.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a) :precision binary64 (+ x (- (+ (tan y) (tan z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + ((tan(y) + tan(z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + ((tan(y) + tan(z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + ((Math.tan(y) + Math.tan(z)) - Math.tan(a));
}
def code(x, y, z, a): return x + ((math.tan(y) + math.tan(z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(tan(y) + tan(z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + ((tan(y) + tan(z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(\tan y + \tan z\right) - \tan a\right)
\end{array}
Initial program 77.8%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
expm1-log1p-u91.5%
expm1-undefine91.5%
log1p-undefine91.5%
add-exp-log99.7%
Applied egg-rr99.7%
associate--l+99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 77.9%
Final simplification77.9%
(FPCore (x y z a) :precision binary64 (if (<= z -2.4e-42) (pow E (log x)) (if (<= z 8.4e-8) (- (+ x z) (tan a)) (+ x (- (tan z) a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= -2.4e-42) {
tmp = pow(((double) M_E), log(x));
} else if (z <= 8.4e-8) {
tmp = (x + z) - tan(a);
} else {
tmp = x + (tan(z) - a);
}
return tmp;
}
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= -2.4e-42) {
tmp = Math.pow(Math.E, Math.log(x));
} else if (z <= 8.4e-8) {
tmp = (x + z) - Math.tan(a);
} else {
tmp = x + (Math.tan(z) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if z <= -2.4e-42: tmp = math.pow(math.e, math.log(x)) elif z <= 8.4e-8: tmp = (x + z) - math.tan(a) else: tmp = x + (math.tan(z) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if (z <= -2.4e-42) tmp = exp(1) ^ log(x); elseif (z <= 8.4e-8) tmp = Float64(Float64(x + z) - tan(a)); else tmp = Float64(x + Float64(tan(z) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= -2.4e-42) tmp = 2.71828182845904523536 ^ log(x); elseif (z <= 8.4e-8) tmp = (x + z) - tan(a); else tmp = x + (tan(z) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[z, -2.4e-42], N[Power[E, N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 8.4e-8], N[(N[(x + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{-42}:\\
\;\;\;\;{e}^{\log x}\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{-8}:\\
\;\;\;\;\left(x + z\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\end{array}
\end{array}
if z < -2.40000000000000003e-42Initial program 52.8%
add-exp-log51.0%
+-commutative51.0%
associate-+l-51.0%
Applied egg-rr51.0%
Taylor expanded in x around inf 22.5%
mul-1-neg22.5%
log-rec22.5%
remove-double-neg22.5%
Simplified22.5%
*-un-lft-identity22.5%
exp-prod22.5%
Applied egg-rr22.5%
exp-1-e22.5%
Simplified22.5%
if -2.40000000000000003e-42 < z < 8.39999999999999978e-8Initial program 99.9%
Taylor expanded in y around 0 58.1%
Taylor expanded in z around 0 58.1%
associate-+r-58.1%
Applied egg-rr58.1%
if 8.39999999999999978e-8 < z Initial program 67.0%
Taylor expanded in y around 0 65.7%
Taylor expanded in a around 0 38.9%
associate-+r+38.9%
mul-1-neg38.9%
unsub-neg38.9%
Simplified38.9%
tan-quot39.0%
associate-+l-39.0%
Applied egg-rr39.0%
Final simplification42.9%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 77.8%
Final simplification77.8%
(FPCore (x y z a) :precision binary64 (if (<= z -2.4e-42) (exp (log x)) (if (<= z 8.4e-8) (- (+ x z) (tan a)) (+ x (- (tan z) a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= -2.4e-42) {
tmp = exp(log(x));
} else if (z <= 8.4e-8) {
tmp = (x + z) - tan(a);
} else {
tmp = x + (tan(z) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-2.4d-42)) then
tmp = exp(log(x))
else if (z <= 8.4d-8) then
tmp = (x + z) - tan(a)
else
tmp = x + (tan(z) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= -2.4e-42) {
tmp = Math.exp(Math.log(x));
} else if (z <= 8.4e-8) {
tmp = (x + z) - Math.tan(a);
} else {
tmp = x + (Math.tan(z) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if z <= -2.4e-42: tmp = math.exp(math.log(x)) elif z <= 8.4e-8: tmp = (x + z) - math.tan(a) else: tmp = x + (math.tan(z) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if (z <= -2.4e-42) tmp = exp(log(x)); elseif (z <= 8.4e-8) tmp = Float64(Float64(x + z) - tan(a)); else tmp = Float64(x + Float64(tan(z) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= -2.4e-42) tmp = exp(log(x)); elseif (z <= 8.4e-8) tmp = (x + z) - tan(a); else tmp = x + (tan(z) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[z, -2.4e-42], N[Exp[N[Log[x], $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 8.4e-8], N[(N[(x + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{-42}:\\
\;\;\;\;e^{\log x}\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{-8}:\\
\;\;\;\;\left(x + z\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\end{array}
\end{array}
if z < -2.40000000000000003e-42Initial program 52.8%
add-exp-log51.0%
+-commutative51.0%
associate-+l-51.0%
Applied egg-rr51.0%
Taylor expanded in x around inf 22.5%
mul-1-neg22.5%
log-rec22.5%
remove-double-neg22.5%
Simplified22.5%
if -2.40000000000000003e-42 < z < 8.39999999999999978e-8Initial program 99.9%
Taylor expanded in y around 0 58.1%
Taylor expanded in z around 0 58.1%
associate-+r-58.1%
Applied egg-rr58.1%
if 8.39999999999999978e-8 < z Initial program 67.0%
Taylor expanded in y around 0 65.7%
Taylor expanded in a around 0 38.9%
associate-+r+38.9%
mul-1-neg38.9%
unsub-neg38.9%
Simplified38.9%
tan-quot39.0%
associate-+l-39.0%
Applied egg-rr39.0%
Final simplification42.9%
(FPCore (x y z a) :precision binary64 (+ x (- (tan z) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan(z) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan(z) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan(z) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan(z) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(z) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan(z) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan z - \tan a\right)
\end{array}
Initial program 77.8%
Taylor expanded in y around 0 57.0%
tan-quot57.0%
*-un-lft-identity57.0%
Applied egg-rr57.0%
*-lft-identity57.0%
Simplified57.0%
Final simplification57.0%
(FPCore (x y z a) :precision binary64 (if (<= z -6.2e-46) x (if (<= z 1.3) (+ x (- z (tan a))) x)))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= -6.2e-46) {
tmp = x;
} else if (z <= 1.3) {
tmp = x + (z - tan(a));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-6.2d-46)) then
tmp = x
else if (z <= 1.3d0) then
tmp = x + (z - tan(a))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= -6.2e-46) {
tmp = x;
} else if (z <= 1.3) {
tmp = x + (z - Math.tan(a));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if z <= -6.2e-46: tmp = x elif z <= 1.3: tmp = x + (z - math.tan(a)) else: tmp = x return tmp
function code(x, y, z, a) tmp = 0.0 if (z <= -6.2e-46) tmp = x; elseif (z <= 1.3) tmp = Float64(x + Float64(z - tan(a))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= -6.2e-46) tmp = x; elseif (z <= 1.3) tmp = x + (z - tan(a)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[z, -6.2e-46], x, If[LessEqual[z, 1.3], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{-46}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.3:\\
\;\;\;\;x + \left(z - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.2000000000000002e-46 or 1.30000000000000004 < z Initial program 59.0%
Taylor expanded in x around inf 21.8%
if -6.2000000000000002e-46 < z < 1.30000000000000004Initial program 99.4%
Taylor expanded in y around 0 58.2%
Taylor expanded in z around 0 58.2%
Final simplification38.7%
(FPCore (x y z a) :precision binary64 (if (<= z -6.2e-46) x (if (<= z 8.4e-8) (+ x (- z (tan a))) (+ x (- (tan z) a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= -6.2e-46) {
tmp = x;
} else if (z <= 8.4e-8) {
tmp = x + (z - tan(a));
} else {
tmp = x + (tan(z) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-6.2d-46)) then
tmp = x
else if (z <= 8.4d-8) then
tmp = x + (z - tan(a))
else
tmp = x + (tan(z) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= -6.2e-46) {
tmp = x;
} else if (z <= 8.4e-8) {
tmp = x + (z - Math.tan(a));
} else {
tmp = x + (Math.tan(z) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if z <= -6.2e-46: tmp = x elif z <= 8.4e-8: tmp = x + (z - math.tan(a)) else: tmp = x + (math.tan(z) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if (z <= -6.2e-46) tmp = x; elseif (z <= 8.4e-8) tmp = Float64(x + Float64(z - tan(a))); else tmp = Float64(x + Float64(tan(z) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= -6.2e-46) tmp = x; elseif (z <= 8.4e-8) tmp = x + (z - tan(a)); else tmp = x + (tan(z) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[z, -6.2e-46], x, If[LessEqual[z, 8.4e-8], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{-46}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{-8}:\\
\;\;\;\;x + \left(z - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\end{array}
\end{array}
if z < -6.2000000000000002e-46Initial program 52.8%
Taylor expanded in x around inf 22.5%
if -6.2000000000000002e-46 < z < 8.39999999999999978e-8Initial program 99.9%
Taylor expanded in y around 0 58.1%
Taylor expanded in z around 0 58.1%
if 8.39999999999999978e-8 < z Initial program 67.0%
Taylor expanded in y around 0 65.7%
Taylor expanded in a around 0 38.9%
associate-+r+38.9%
mul-1-neg38.9%
unsub-neg38.9%
Simplified38.9%
tan-quot39.0%
associate-+l-39.0%
Applied egg-rr39.0%
Final simplification42.8%
(FPCore (x y z a) :precision binary64 (if (<= z -6.2e-46) x (if (<= z 8.4e-8) (- (+ x z) (tan a)) (+ x (- (tan z) a)))))
double code(double x, double y, double z, double a) {
double tmp;
if (z <= -6.2e-46) {
tmp = x;
} else if (z <= 8.4e-8) {
tmp = (x + z) - tan(a);
} else {
tmp = x + (tan(z) - a);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-6.2d-46)) then
tmp = x
else if (z <= 8.4d-8) then
tmp = (x + z) - tan(a)
else
tmp = x + (tan(z) - a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if (z <= -6.2e-46) {
tmp = x;
} else if (z <= 8.4e-8) {
tmp = (x + z) - Math.tan(a);
} else {
tmp = x + (Math.tan(z) - a);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if z <= -6.2e-46: tmp = x elif z <= 8.4e-8: tmp = (x + z) - math.tan(a) else: tmp = x + (math.tan(z) - a) return tmp
function code(x, y, z, a) tmp = 0.0 if (z <= -6.2e-46) tmp = x; elseif (z <= 8.4e-8) tmp = Float64(Float64(x + z) - tan(a)); else tmp = Float64(x + Float64(tan(z) - a)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if (z <= -6.2e-46) tmp = x; elseif (z <= 8.4e-8) tmp = (x + z) - tan(a); else tmp = x + (tan(z) - a); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[z, -6.2e-46], x, If[LessEqual[z, 8.4e-8], N[(N[(x + z), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{-46}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{-8}:\\
\;\;\;\;\left(x + z\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - a\right)\\
\end{array}
\end{array}
if z < -6.2000000000000002e-46Initial program 52.8%
Taylor expanded in x around inf 22.5%
if -6.2000000000000002e-46 < z < 8.39999999999999978e-8Initial program 99.9%
Taylor expanded in y around 0 58.1%
Taylor expanded in z around 0 58.1%
associate-+r-58.1%
Applied egg-rr58.1%
if 8.39999999999999978e-8 < z Initial program 67.0%
Taylor expanded in y around 0 65.7%
Taylor expanded in a around 0 38.9%
associate-+r+38.9%
mul-1-neg38.9%
unsub-neg38.9%
Simplified38.9%
tan-quot39.0%
associate-+l-39.0%
Applied egg-rr39.0%
Final simplification42.9%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 77.8%
Taylor expanded in x around inf 29.5%
Final simplification29.5%
herbie shell --seed 2024072
(FPCore (x y z a)
:name "tan-example (used to crash)"
:precision binary64
:pre (and (and (and (or (== x 0.0) (and (<= 0.5884142 x) (<= x 505.5909))) (or (and (<= -1.796658e+308 y) (<= y -9.425585e-310)) (and (<= 1.284938e-309 y) (<= y 1.751224e+308)))) (or (and (<= -1.776707e+308 z) (<= z -8.599796e-310)) (and (<= 3.293145e-311 z) (<= z 1.725154e+308)))) (or (and (<= -1.796658e+308 a) (<= a -9.425585e-310)) (and (<= 1.284938e-309 a) (<= a 1.751224e+308))))
(+ x (- (tan (+ y z)) (tan a))))