
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 93.6%
+-commutative93.6%
*-commutative93.6%
associate-*l*98.0%
fma-def98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
Initial program 93.6%
associate-*l*97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.25e-55) (not (<= t 1.5e-55))) (+ x (* (tanh (/ t y)) (* z y))) (+ x (- (* z t) (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.25e-55) || !(t <= 1.5e-55)) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = x + ((z * t) - (z * x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-2.25d-55)) .or. (.not. (t <= 1.5d-55))) then
tmp = x + (tanh((t / y)) * (z * y))
else
tmp = x + ((z * t) - (z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.25e-55) || !(t <= 1.5e-55)) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + ((z * t) - (z * x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -2.25e-55) or not (t <= 1.5e-55): tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + ((z * t) - (z * x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -2.25e-55) || !(t <= 1.5e-55)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = Float64(x + Float64(Float64(z * t) - Float64(z * x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -2.25e-55) || ~((t <= 1.5e-55))) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + ((z * t) - (z * x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.25e-55], N[Not[LessEqual[t, 1.5e-55]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z * t), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.25 \cdot 10^{-55} \lor \neg \left(t \leq 1.5 \cdot 10^{-55}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot t - z \cdot x\right)\\
\end{array}
\end{array}
if t < -2.24999999999999985e-55 or 1.50000000000000008e-55 < t Initial program 96.8%
Taylor expanded in x around 0 12.7%
associate-/r*12.7%
div-sub12.7%
rec-exp12.7%
rec-exp12.7%
tanh-def-a89.7%
Simplified89.7%
if -2.24999999999999985e-55 < t < 1.50000000000000008e-55Initial program 89.3%
+-commutative89.3%
*-commutative89.3%
associate-*l*95.3%
fma-def95.3%
Simplified95.3%
Taylor expanded in y around inf 89.2%
Taylor expanded in t around 0 89.2%
Final simplification89.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* z t))))
(if (<= y -0.00102)
t_1
(if (<= y 4.4e+73)
x
(if (or (<= y 2.5e+211) (not (<= y 5.8e+261))) t_1 (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (z * t);
double tmp;
if (y <= -0.00102) {
tmp = t_1;
} else if (y <= 4.4e+73) {
tmp = x;
} else if ((y <= 2.5e+211) || !(y <= 5.8e+261)) {
tmp = t_1;
} else {
tmp = z * (t - x);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x + (z * t)
if (y <= (-0.00102d0)) then
tmp = t_1
else if (y <= 4.4d+73) then
tmp = x
else if ((y <= 2.5d+211) .or. (.not. (y <= 5.8d+261))) then
tmp = t_1
else
tmp = z * (t - x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (z * t);
double tmp;
if (y <= -0.00102) {
tmp = t_1;
} else if (y <= 4.4e+73) {
tmp = x;
} else if ((y <= 2.5e+211) || !(y <= 5.8e+261)) {
tmp = t_1;
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (z * t) tmp = 0 if y <= -0.00102: tmp = t_1 elif y <= 4.4e+73: tmp = x elif (y <= 2.5e+211) or not (y <= 5.8e+261): tmp = t_1 else: tmp = z * (t - x) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(z * t)) tmp = 0.0 if (y <= -0.00102) tmp = t_1; elseif (y <= 4.4e+73) tmp = x; elseif ((y <= 2.5e+211) || !(y <= 5.8e+261)) tmp = t_1; else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (z * t); tmp = 0.0; if (y <= -0.00102) tmp = t_1; elseif (y <= 4.4e+73) tmp = x; elseif ((y <= 2.5e+211) || ~((y <= 5.8e+261))) tmp = t_1; else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.00102], t$95$1, If[LessEqual[y, 4.4e+73], x, If[Or[LessEqual[y, 2.5e+211], N[Not[LessEqual[y, 5.8e+261]], $MachinePrecision]], t$95$1, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot t\\
\mathbf{if}\;y \leq -0.00102:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+211} \lor \neg \left(y \leq 5.8 \cdot 10^{+261}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < -0.00102 or 4.4e73 < y < 2.4999999999999998e211 or 5.8e261 < y Initial program 89.5%
Taylor expanded in x around 0 46.0%
associate-/r*46.0%
div-sub46.0%
rec-exp46.0%
rec-exp46.0%
tanh-def-a79.8%
Simplified79.8%
Taylor expanded in y around inf 71.2%
if -0.00102 < y < 4.4e73Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 81.0%
if 2.4999999999999998e211 < y < 5.8e261Initial program 69.5%
+-commutative69.5%
*-commutative69.5%
associate-*l*83.8%
fma-def83.8%
Simplified83.8%
Taylor expanded in y around inf 88.7%
Taylor expanded in z around inf 76.7%
Final simplification76.5%
(FPCore (x y z t)
:precision binary64
(if (<= y -5.5e+82)
(- x (* z x))
(if (<= y 2.6e+73)
x
(if (or (<= y 1.45e+215) (not (<= y 2.5e+261)))
(+ x (* z t))
(* z (- t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e+82) {
tmp = x - (z * x);
} else if (y <= 2.6e+73) {
tmp = x;
} else if ((y <= 1.45e+215) || !(y <= 2.5e+261)) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-5.5d+82)) then
tmp = x - (z * x)
else if (y <= 2.6d+73) then
tmp = x
else if ((y <= 1.45d+215) .or. (.not. (y <= 2.5d+261))) then
tmp = x + (z * t)
else
tmp = z * (t - x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e+82) {
tmp = x - (z * x);
} else if (y <= 2.6e+73) {
tmp = x;
} else if ((y <= 1.45e+215) || !(y <= 2.5e+261)) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5.5e+82: tmp = x - (z * x) elif y <= 2.6e+73: tmp = x elif (y <= 1.45e+215) or not (y <= 2.5e+261): tmp = x + (z * t) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5e+82) tmp = Float64(x - Float64(z * x)); elseif (y <= 2.6e+73) tmp = x; elseif ((y <= 1.45e+215) || !(y <= 2.5e+261)) tmp = Float64(x + Float64(z * t)); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -5.5e+82) tmp = x - (z * x); elseif (y <= 2.6e+73) tmp = x; elseif ((y <= 1.45e+215) || ~((y <= 2.5e+261))) tmp = x + (z * t); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5e+82], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+73], x, If[Or[LessEqual[y, 1.45e+215], N[Not[LessEqual[y, 2.5e+261]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+82}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+215} \lor \neg \left(y \leq 2.5 \cdot 10^{+261}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < -5.49999999999999997e82Initial program 87.9%
+-commutative87.9%
*-commutative87.9%
associate-*l*99.0%
fma-def99.0%
Simplified99.0%
Taylor expanded in y around inf 91.7%
Taylor expanded in t around 0 82.8%
+-commutative82.8%
mul-1-neg82.8%
unsub-neg82.8%
Simplified82.8%
if -5.49999999999999997e82 < y < 2.6000000000000001e73Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 77.5%
if 2.6000000000000001e73 < y < 1.45e215 or 2.5e261 < y Initial program 88.0%
Taylor expanded in x around 0 45.6%
associate-/r*45.6%
div-sub45.6%
rec-exp45.6%
rec-exp45.6%
tanh-def-a80.8%
Simplified80.8%
Taylor expanded in y around inf 78.3%
if 1.45e215 < y < 2.5e261Initial program 69.5%
+-commutative69.5%
*-commutative69.5%
associate-*l*83.8%
fma-def83.8%
Simplified83.8%
Taylor expanded in y around inf 88.7%
Taylor expanded in z around inf 76.7%
Final simplification78.7%
(FPCore (x y z t) :precision binary64 (if (<= y -1.4) (+ x (* z (- t x))) (if (<= y 2.7e+73) x (+ x (- (* z t) (* z x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4) {
tmp = x + (z * (t - x));
} else if (y <= 2.7e+73) {
tmp = x;
} else {
tmp = x + ((z * t) - (z * x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-1.4d0)) then
tmp = x + (z * (t - x))
else if (y <= 2.7d+73) then
tmp = x
else
tmp = x + ((z * t) - (z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4) {
tmp = x + (z * (t - x));
} else if (y <= 2.7e+73) {
tmp = x;
} else {
tmp = x + ((z * t) - (z * x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.4: tmp = x + (z * (t - x)) elif y <= 2.7e+73: tmp = x else: tmp = x + ((z * t) - (z * x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.4) tmp = Float64(x + Float64(z * Float64(t - x))); elseif (y <= 2.7e+73) tmp = x; else tmp = Float64(x + Float64(Float64(z * t) - Float64(z * x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.4) tmp = x + (z * (t - x)); elseif (y <= 2.7e+73) tmp = x; else tmp = x + ((z * t) - (z * x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.4], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e+73], x, N[(x + N[(N[(z * t), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+73}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot t - z \cdot x\right)\\
\end{array}
\end{array}
if y < -1.3999999999999999Initial program 90.4%
+-commutative90.4%
*-commutative90.4%
associate-*l*99.2%
fma-def99.2%
Simplified99.2%
Taylor expanded in y around inf 84.6%
if -1.3999999999999999 < y < 2.6999999999999999e73Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 81.0%
if 2.6999999999999999e73 < y Initial program 82.7%
+-commutative82.7%
*-commutative82.7%
associate-*l*91.9%
fma-def91.9%
Simplified91.9%
Taylor expanded in y around inf 87.7%
Taylor expanded in t around 0 87.7%
Final simplification83.4%
(FPCore (x y z t) :precision binary64 (if (or (<= y -560.0) (not (<= y 2.6e+73))) (+ x (* z (- t x))) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -560.0) || !(y <= 2.6e+73)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-560.0d0)) .or. (.not. (y <= 2.6d+73))) then
tmp = x + (z * (t - x))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -560.0) || !(y <= 2.6e+73)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -560.0) or not (y <= 2.6e+73): tmp = x + (z * (t - x)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -560.0) || !(y <= 2.6e+73)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -560.0) || ~((y <= 2.6e+73))) tmp = x + (z * (t - x)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -560.0], N[Not[LessEqual[y, 2.6e+73]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -560 \lor \neg \left(y \leq 2.6 \cdot 10^{+73}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -560 or 2.6000000000000001e73 < y Initial program 86.9%
+-commutative86.9%
*-commutative86.9%
associate-*l*95.9%
fma-def95.9%
Simplified95.9%
Taylor expanded in y around inf 86.0%
if -560 < y < 2.6000000000000001e73Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 81.0%
Final simplification83.4%
(FPCore (x y z t) :precision binary64 (if (<= z -7.8e+272) (* z t) (if (or (<= z -7e+142) (not (<= z 2.65e+109))) (* z (- x)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.8e+272) {
tmp = z * t;
} else if ((z <= -7e+142) || !(z <= 2.65e+109)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-7.8d+272)) then
tmp = z * t
else if ((z <= (-7d+142)) .or. (.not. (z <= 2.65d+109))) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.8e+272) {
tmp = z * t;
} else if ((z <= -7e+142) || !(z <= 2.65e+109)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.8e+272: tmp = z * t elif (z <= -7e+142) or not (z <= 2.65e+109): tmp = z * -x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.8e+272) tmp = Float64(z * t); elseif ((z <= -7e+142) || !(z <= 2.65e+109)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.8e+272) tmp = z * t; elseif ((z <= -7e+142) || ~((z <= 2.65e+109))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.8e+272], N[(z * t), $MachinePrecision], If[Or[LessEqual[z, -7e+142], N[Not[LessEqual[z, 2.65e+109]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{+272}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;z \leq -7 \cdot 10^{+142} \lor \neg \left(z \leq 2.65 \cdot 10^{+109}\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -7.8e272Initial program 74.2%
Taylor expanded in x around 0 9.4%
associate-/r*9.4%
div-sub9.4%
rec-exp9.4%
rec-exp9.4%
tanh-def-a52.1%
Simplified52.1%
Taylor expanded in y around inf 53.7%
Taylor expanded in t around inf 53.7%
if -7.8e272 < z < -6.99999999999999995e142 or 2.65000000000000013e109 < z Initial program 80.8%
+-commutative80.8%
*-commutative80.8%
associate-*l*91.9%
fma-def91.9%
Simplified91.9%
Taylor expanded in y around inf 63.5%
Taylor expanded in z around inf 63.5%
Taylor expanded in t around 0 50.9%
mul-1-neg50.9%
distribute-rgt-neg-in50.9%
Simplified50.9%
if -6.99999999999999995e142 < z < 2.65000000000000013e109Initial program 98.0%
+-commutative98.0%
*-commutative98.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 76.1%
Final simplification70.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5.2e+142) (not (<= z 5.5e+87))) (* z (- t x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.2e+142) || !(z <= 5.5e+87)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-5.2d+142)) .or. (.not. (z <= 5.5d+87))) then
tmp = z * (t - x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5.2e+142) || !(z <= 5.5e+87)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5.2e+142) or not (z <= 5.5e+87): tmp = z * (t - x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5.2e+142) || !(z <= 5.5e+87)) tmp = Float64(z * Float64(t - x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5.2e+142) || ~((z <= 5.5e+87))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.2e+142], N[Not[LessEqual[z, 5.5e+87]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+142} \lor \neg \left(z \leq 5.5 \cdot 10^{+87}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -5.20000000000000043e142 or 5.50000000000000022e87 < z Initial program 78.8%
+-commutative78.8%
*-commutative78.8%
associate-*l*92.0%
fma-def92.0%
Simplified92.0%
Taylor expanded in y around inf 65.0%
Taylor expanded in z around inf 65.0%
if -5.20000000000000043e142 < z < 5.50000000000000022e87Initial program 98.5%
+-commutative98.5%
*-commutative98.5%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around 0 76.9%
Final simplification73.9%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.6%
+-commutative93.6%
*-commutative93.6%
associate-*l*98.0%
fma-def98.0%
Simplified98.0%
Taylor expanded in z around 0 64.3%
Final simplification64.3%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2023187
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:herbie-target
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))