
(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 12 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}
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 3.2e+217) (+ x (* y (- (* z (tanh (/ t y))) (* z (tanh (/ x y)))))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.2e+217) {
tmp = x + (y * ((z * tanh((t / y))) - (z * tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 3.2d+217) then
tmp = x + (y * ((z * tanh((t / y))) - (z * tanh((x / y)))))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.2e+217) {
tmp = x + (y * ((z * Math.tanh((t / y))) - (z * Math.tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 3.2e+217: tmp = x + (y * ((z * math.tanh((t / y))) - (z * math.tanh((x / y))))) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 3.2e+217) tmp = Float64(x + Float64(y * Float64(Float64(z * tanh(Float64(t / y))) - Float64(z * tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.2e+217) tmp = x + (y * ((z * tanh((t / y))) - (z * tanh((x / y))))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 3.2e+217], N[(x + N[(y * N[(N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+217}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right) - z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.2000000000000001e217Initial program 94.4%
associate-*l*97.1%
Simplified97.1%
sub-neg97.1%
distribute-rgt-in97.1%
Applied egg-rr97.1%
if 3.2000000000000001e217 < y Initial program 86.5%
+-commutative86.5%
*-commutative86.5%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Final simplification97.2%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
y = abs(y);
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
y = abs(y) function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
NOTE: y should be positive before calling this function 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}
y = |y|\\
\\
\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.9%
+-commutative93.9%
*-commutative93.9%
associate-*l*97.7%
fma-def97.7%
Simplified97.7%
Final simplification97.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 2e+219) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2e+219) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 2d+219) then
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2e+219) {
tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2e+219: tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y))))) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2e+219) tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2e+219) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2e+219], 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], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+219}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.99999999999999993e219Initial program 94.4%
associate-*l*97.1%
Simplified97.1%
if 1.99999999999999993e219 < y Initial program 86.5%
+-commutative86.5%
*-commutative86.5%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Final simplification97.2%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (or (<= t -5.5e-79) (not (<= t 1.26e-16))) (+ x (* y (* z (tanh (/ t y))))) (+ x (* y (- (/ (* z t) y) (* z (tanh (/ x y))))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -5.5e-79) || !(t <= 1.26e-16)) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = x + (y * (((z * t) / y) - (z * tanh((x / y)))));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= (-5.5d-79)) .or. (.not. (t <= 1.26d-16))) then
tmp = x + (y * (z * tanh((t / y))))
else
tmp = x + (y * (((z * t) / y) - (z * tanh((x / y)))))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -5.5e-79) || !(t <= 1.26e-16)) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (y * (((z * t) / y) - (z * Math.tanh((x / y)))));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if (t <= -5.5e-79) or not (t <= 1.26e-16): tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (y * (((z * t) / y) - (z * math.tanh((x / y))))) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if ((t <= -5.5e-79) || !(t <= 1.26e-16)) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(y * Float64(Float64(Float64(z * t) / y) - Float64(z * tanh(Float64(x / y)))))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -5.5e-79) || ~((t <= 1.26e-16))) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (y * (((z * t) / y) - (z * tanh((x / y))))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[Or[LessEqual[t, -5.5e-79], N[Not[LessEqual[t, 1.26e-16]], $MachinePrecision]], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(N[(z * t), $MachinePrecision] / y), $MachinePrecision] - N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.5 \cdot 10^{-79} \lor \neg \left(t \leq 1.26 \cdot 10^{-16}\right):\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(\frac{z \cdot t}{y} - z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -5.4999999999999997e-79 or 1.26000000000000001e-16 < t Initial program 96.2%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around 0 11.9%
*-commutative11.9%
associate-/r*11.9%
div-sub11.9%
rec-exp11.9%
rec-exp11.9%
tanh-def-a88.3%
Simplified88.3%
if -5.4999999999999997e-79 < t < 1.26000000000000001e-16Initial program 90.7%
associate-*l*94.3%
Simplified94.3%
sub-neg94.3%
distribute-rgt-in94.3%
Applied egg-rr94.3%
Taylor expanded in t around 0 87.6%
Final simplification88.1%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 4e-193)
x
(if (<= y 4.8e+75) (+ x (* y (* z t_1))) (+ x (* z (- (* y t_1) x)))))))y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 4e-193) {
tmp = x;
} else if (y <= 4.8e+75) {
tmp = x + (y * (z * t_1));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 = tanh((t / y))
if (y <= 4d-193) then
tmp = x
else if (y <= 4.8d+75) then
tmp = x + (y * (z * t_1))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 4e-193) {
tmp = x;
} else if (y <= 4.8e+75) {
tmp = x + (y * (z * t_1));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 4e-193: tmp = x elif y <= 4.8e+75: tmp = x + (y * (z * t_1)) else: tmp = x + (z * ((y * t_1) - x)) return tmp
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 4e-193) tmp = x; elseif (y <= 4.8e+75) tmp = Float64(x + Float64(y * Float64(z * t_1))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 4e-193) tmp = x; elseif (y <= 4.8e+75) tmp = x + (y * (z * t_1)); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 4e-193], x, If[LessEqual[y, 4.8e+75], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 4 \cdot 10^{-193}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+75}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 4.0000000000000002e-193Initial program 93.3%
+-commutative93.3%
*-commutative93.3%
associate-*l*96.4%
fma-def96.4%
Simplified96.4%
Taylor expanded in z around 0 62.7%
if 4.0000000000000002e-193 < y < 4.8e75Initial program 99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 27.6%
*-commutative27.6%
associate-/r*27.6%
div-sub27.6%
rec-exp27.6%
rec-exp27.6%
tanh-def-a84.6%
Simplified84.6%
if 4.8e75 < y Initial program 87.6%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 49.8%
*-commutative49.8%
mul-1-neg49.8%
unsub-neg49.8%
Simplified88.8%
Taylor expanded in z around 0 49.8%
*-commutative49.8%
Simplified96.4%
Final simplification72.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (or (<= x -9.2e+100) (not (<= x 3.4e-102))) (- x (* z (* y (tanh (/ x y))))) (+ x (* y (* z (tanh (/ t y)))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -9.2e+100) || !(x <= 3.4e-102)) {
tmp = x - (z * (y * tanh((x / y))));
} else {
tmp = x + (y * (z * tanh((t / y))));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 ((x <= (-9.2d+100)) .or. (.not. (x <= 3.4d-102))) then
tmp = x - (z * (y * tanh((x / y))))
else
tmp = x + (y * (z * tanh((t / y))))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -9.2e+100) || !(x <= 3.4e-102)) {
tmp = x - (z * (y * Math.tanh((x / y))));
} else {
tmp = x + (y * (z * Math.tanh((t / y))));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if (x <= -9.2e+100) or not (x <= 3.4e-102): tmp = x - (z * (y * math.tanh((x / y)))) else: tmp = x + (y * (z * math.tanh((t / y)))) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if ((x <= -9.2e+100) || !(x <= 3.4e-102)) tmp = Float64(x - Float64(z * Float64(y * tanh(Float64(x / y))))); else tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -9.2e+100) || ~((x <= 3.4e-102))) tmp = x - (z * (y * tanh((x / y)))); else tmp = x + (y * (z * tanh((t / y)))); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[Or[LessEqual[x, -9.2e+100], N[Not[LessEqual[x, 3.4e-102]], $MachinePrecision]], N[(x - N[(z * N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+100} \lor \neg \left(x \leq 3.4 \cdot 10^{-102}\right):\\
\;\;\;\;x - z \cdot \left(y \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\end{array}
\end{array}
if x < -9.1999999999999996e100 or 3.40000000000000013e-102 < x Initial program 96.9%
associate-*l*99.9%
Simplified99.9%
sub-neg99.9%
distribute-rgt-in99.9%
Applied egg-rr99.9%
Taylor expanded in t around 0 76.3%
Taylor expanded in t around 0 13.5%
associate-*r/13.5%
*-commutative13.5%
associate-*r*13.5%
associate-*l/13.5%
associate-*r/13.5%
mul-1-neg13.5%
distribute-lft-neg-out13.5%
Simplified94.8%
if -9.1999999999999996e100 < x < 3.40000000000000013e-102Initial program 91.1%
associate-*l*94.0%
Simplified94.0%
Taylor expanded in x around 0 15.7%
*-commutative15.7%
associate-/r*15.7%
div-sub15.7%
rec-exp15.7%
rec-exp15.7%
tanh-def-a79.6%
Simplified79.6%
Final simplification86.9%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 7e-194) x (if (<= y 5.1e+129) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e-194) {
tmp = x;
} else if (y <= 5.1e+129) {
tmp = x + (y * (z * tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 7d-194) then
tmp = x
else if (y <= 5.1d+129) then
tmp = x + (y * (z * tanh((t / y))))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e-194) {
tmp = x;
} else if (y <= 5.1e+129) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 7e-194: tmp = x elif y <= 5.1e+129: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 7e-194) tmp = x; elseif (y <= 5.1e+129) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7e-194) tmp = x; elseif (y <= 5.1e+129) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 7e-194], x, If[LessEqual[y, 5.1e+129], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-194}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{+129}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7.0000000000000006e-194Initial program 93.3%
+-commutative93.3%
*-commutative93.3%
associate-*l*96.4%
fma-def96.4%
Simplified96.4%
Taylor expanded in z around 0 62.7%
if 7.0000000000000006e-194 < y < 5.09999999999999996e129Initial program 99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 28.6%
*-commutative28.6%
associate-/r*28.6%
div-sub28.6%
rec-exp28.6%
rec-exp28.6%
tanh-def-a84.7%
Simplified84.7%
if 5.09999999999999996e129 < y Initial program 85.8%
+-commutative85.8%
*-commutative85.8%
associate-*l*99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in y around inf 88.8%
Final simplification71.6%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(if (<= y 2.7e+68)
x
(if (or (<= y 2.25e+154) (not (<= y 7.5e+178)))
(+ x (* z t))
(- x (* z x)))))y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+68) {
tmp = x;
} else if ((y <= 2.25e+154) || !(y <= 7.5e+178)) {
tmp = x + (z * t);
} else {
tmp = x - (z * x);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 2.7d+68) then
tmp = x
else if ((y <= 2.25d+154) .or. (.not. (y <= 7.5d+178))) then
tmp = x + (z * t)
else
tmp = x - (z * x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.7e+68) {
tmp = x;
} else if ((y <= 2.25e+154) || !(y <= 7.5e+178)) {
tmp = x + (z * t);
} else {
tmp = x - (z * x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2.7e+68: tmp = x elif (y <= 2.25e+154) or not (y <= 7.5e+178): tmp = x + (z * t) else: tmp = x - (z * x) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2.7e+68) tmp = x; elseif ((y <= 2.25e+154) || !(y <= 7.5e+178)) tmp = Float64(x + Float64(z * t)); else tmp = Float64(x - Float64(z * x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.7e+68) tmp = x; elseif ((y <= 2.25e+154) || ~((y <= 7.5e+178))) tmp = x + (z * t); else tmp = x - (z * x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2.7e+68], x, If[Or[LessEqual[y, 2.25e+154], N[Not[LessEqual[y, 7.5e+178]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{+68}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+154} \lor \neg \left(y \leq 7.5 \cdot 10^{+178}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < 2.69999999999999991e68Initial program 95.0%
+-commutative95.0%
*-commutative95.0%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Taylor expanded in z around 0 63.3%
if 2.69999999999999991e68 < y < 2.25000000000000005e154 or 7.4999999999999995e178 < y Initial program 86.6%
+-commutative86.6%
*-commutative86.6%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around inf 81.2%
Taylor expanded in t around inf 65.0%
if 2.25000000000000005e154 < y < 7.4999999999999995e178Initial program 97.4%
associate-*l*97.4%
Simplified97.4%
Taylor expanded in x around 0 66.7%
*-commutative66.7%
mul-1-neg66.7%
unsub-neg66.7%
Simplified100.0%
Taylor expanded in z around 0 66.7%
*-commutative66.7%
Simplified100.0%
Taylor expanded in x around inf 85.7%
neg-mul-185.7%
distribute-rgt1-in85.7%
distribute-lft-neg-in85.7%
unsub-neg85.7%
Simplified85.7%
Final simplification64.1%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 7.5e+124) x (if (<= y 8e+160) (* z t) (if (<= y 1.4e+187) x (* z t)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.5e+124) {
tmp = x;
} else if (y <= 8e+160) {
tmp = z * t;
} else if (y <= 1.4e+187) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 7.5d+124) then
tmp = x
else if (y <= 8d+160) then
tmp = z * t
else if (y <= 1.4d+187) then
tmp = x
else
tmp = z * t
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.5e+124) {
tmp = x;
} else if (y <= 8e+160) {
tmp = z * t;
} else if (y <= 1.4e+187) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 7.5e+124: tmp = x elif y <= 8e+160: tmp = z * t elif y <= 1.4e+187: tmp = x else: tmp = z * t return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 7.5e+124) tmp = x; elseif (y <= 8e+160) tmp = Float64(z * t); elseif (y <= 1.4e+187) tmp = x; else tmp = Float64(z * t); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7.5e+124) tmp = x; elseif (y <= 8e+160) tmp = z * t; elseif (y <= 1.4e+187) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 7.5e+124], x, If[LessEqual[y, 8e+160], N[(z * t), $MachinePrecision], If[LessEqual[y, 1.4e+187], x, N[(z * t), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{+124}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+160}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+187}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 7.50000000000000038e124 or 8.00000000000000005e160 < y < 1.39999999999999995e187Initial program 95.2%
+-commutative95.2%
*-commutative95.2%
associate-*l*97.4%
fma-def97.4%
Simplified97.4%
Taylor expanded in z around 0 62.9%
if 7.50000000000000038e124 < y < 8.00000000000000005e160 or 1.39999999999999995e187 < y Initial program 83.3%
+-commutative83.3%
*-commutative83.3%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around inf 87.2%
Taylor expanded in t around inf 55.4%
Taylor expanded in t around inf 41.3%
Final simplification60.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.4e+74) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.4e+74) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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.4d+74) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.4e+74) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.4e+74: tmp = x else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.4e+74) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.4e+74) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.4e+74], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+74}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.40000000000000001e74Initial program 95.1%
+-commutative95.1%
*-commutative95.1%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Taylor expanded in z around 0 63.2%
if 1.40000000000000001e74 < y Initial program 87.6%
+-commutative87.6%
*-commutative87.6%
associate-*l*99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in y around inf 82.9%
Final simplification66.2%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 3.4e+68) x (+ x (* z t))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.4e+68) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 3.4d+68) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.4e+68) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 3.4e+68: tmp = x else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 3.4e+68) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.4e+68) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 3.4e+68], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{+68}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 3.40000000000000015e68Initial program 95.0%
+-commutative95.0%
*-commutative95.0%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Taylor expanded in z around 0 63.3%
if 3.40000000000000015e68 < y Initial program 88.2%
+-commutative88.2%
*-commutative88.2%
associate-*l*99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in y around inf 81.3%
Taylor expanded in t around inf 57.8%
Final simplification62.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 x)
y = abs(y);
double code(double x, double y, double z, double t) {
return x;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
return x;
}
y = abs(y) def code(x, y, z, t): return x
y = abs(y) function code(x, y, z, t) return x end
y = abs(y) function tmp = code(x, y, z, t) tmp = x; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := x
\begin{array}{l}
y = |y|\\
\\
x
\end{array}
Initial program 93.9%
+-commutative93.9%
*-commutative93.9%
associate-*l*97.7%
fma-def97.7%
Simplified97.7%
Taylor expanded in z around 0 57.8%
Final simplification57.8%
(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 2023200
(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))))))