
(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 (let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z))))) (if (<= t_1 2e+307) t_1 (+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= 2e+307) {
tmp = t_1;
} else {
tmp = x + (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 + ((tanh((t / y)) - tanh((x / y))) * (y * z))
if (t_1 <= 2d+307) then
tmp = t_1
else
tmp = x + (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 + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= 2e+307) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) tmp = 0 if t_1 <= 2e+307: tmp = t_1 else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))) tmp = 0.0 if (t_1 <= 2e+307) tmp = t_1; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); tmp = 0.0; if (t_1 <= 2e+307) tmp = t_1; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+307], t$95$1, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.99999999999999997e307Initial program 98.3%
if 1.99999999999999997e307 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 57.9%
Taylor expanded in y around inf 94.9%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (fma y (* z (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(y, (z * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(y, Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(y * N[(z * 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(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 95.4%
+-commutative95.4%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.6e-101) (not (<= t 24000000000.0))) (+ x (* z (* y (tanh (/ t y))))) (+ x (* (* y z) (- (/ t y) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.6e-101) || !(t <= 24000000000.0)) {
tmp = x + (z * (y * tanh((t / y))));
} else {
tmp = x + ((y * z) * ((t / y) - tanh((x / y))));
}
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 <= (-1.6d-101)) .or. (.not. (t <= 24000000000.0d0))) then
tmp = x + (z * (y * tanh((t / y))))
else
tmp = x + ((y * z) * ((t / y) - tanh((x / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.6e-101) || !(t <= 24000000000.0)) {
tmp = x + (z * (y * Math.tanh((t / y))));
} else {
tmp = x + ((y * z) * ((t / y) - Math.tanh((x / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.6e-101) or not (t <= 24000000000.0): tmp = x + (z * (y * math.tanh((t / y)))) else: tmp = x + ((y * z) * ((t / y) - math.tanh((x / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.6e-101) || !(t <= 24000000000.0)) tmp = Float64(x + Float64(z * Float64(y * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(Float64(y * z) * Float64(Float64(t / y) - tanh(Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.6e-101) || ~((t <= 24000000000.0))) tmp = x + (z * (y * tanh((t / y)))); else tmp = x + ((y * z) * ((t / y) - tanh((x / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.6e-101], N[Not[LessEqual[t, 24000000000.0]], $MachinePrecision]], N[(x + N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.6 \cdot 10^{-101} \lor \neg \left(t \leq 24000000000\right):\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -1.59999999999999989e-101 or 2.4e10 < t Initial program 96.2%
Taylor expanded in x around 0 10.2%
associate-*r*10.1%
*-commutative10.1%
associate-/r*10.1%
div-sub10.1%
rec-exp10.1%
rec-exp10.1%
tanh-def-a86.0%
associate-*l*89.0%
Simplified89.0%
if -1.59999999999999989e-101 < t < 2.4e10Initial program 94.3%
Taylor expanded in t around 0 87.9%
Final simplification88.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.45e-101) (not (<= t 3500000000.0))) (+ x (* z (* y (tanh (/ t y))))) (- x (* y (* z (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.45e-101) || !(t <= 3500000000.0)) {
tmp = x + (z * (y * tanh((t / y))));
} else {
tmp = x - (y * (z * tanh((x / y))));
}
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 <= (-1.45d-101)) .or. (.not. (t <= 3500000000.0d0))) then
tmp = x + (z * (y * tanh((t / y))))
else
tmp = x - (y * (z * tanh((x / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.45e-101) || !(t <= 3500000000.0)) {
tmp = x + (z * (y * Math.tanh((t / y))));
} else {
tmp = x - (y * (z * Math.tanh((x / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.45e-101) or not (t <= 3500000000.0): tmp = x + (z * (y * math.tanh((t / y)))) else: tmp = x - (y * (z * math.tanh((x / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.45e-101) || !(t <= 3500000000.0)) tmp = Float64(x + Float64(z * Float64(y * tanh(Float64(t / y))))); else tmp = Float64(x - Float64(y * Float64(z * tanh(Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.45e-101) || ~((t <= 3500000000.0))) tmp = x + (z * (y * tanh((t / y)))); else tmp = x - (y * (z * tanh((x / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.45e-101], N[Not[LessEqual[t, 3500000000.0]], $MachinePrecision]], N[(x + N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-101} \lor \neg \left(t \leq 3500000000\right):\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -1.45e-101 or 3.5e9 < t Initial program 96.2%
Taylor expanded in x around 0 10.2%
associate-*r*10.1%
*-commutative10.1%
associate-/r*10.1%
div-sub10.1%
rec-exp10.1%
rec-exp10.1%
tanh-def-a86.0%
associate-*l*89.0%
Simplified89.0%
if -1.45e-101 < t < 3.5e9Initial program 94.3%
flip--74.1%
associate-*r/74.1%
pow274.1%
pow274.1%
Applied egg-rr74.1%
frac-2neg74.1%
neg-sub074.1%
div-sub74.1%
neg-mul-174.1%
metadata-eval74.1%
times-frac74.1%
metadata-eval74.1%
Applied egg-rr80.6%
div094.3%
neg-sub094.3%
distribute-rgt-neg-in94.3%
associate-/l*94.2%
Simplified94.2%
Taylor expanded in t around 0 17.0%
associate-*r*17.0%
neg-mul-117.0%
associate-/r*17.0%
rec-exp17.0%
div-sub17.0%
rec-exp17.0%
tanh-def-a85.3%
Simplified85.3%
Final simplification87.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.22e+120) (+ x (* z (* y (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.22e+120) {
tmp = x + (z * (y * tanh((t / y))));
} else {
tmp = x + (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 <= 1.22d+120) then
tmp = x + (z * (y * tanh((t / y))))
else
tmp = x + (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 <= 1.22e+120) {
tmp = x + (z * (y * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.22e+120: tmp = x + (z * (y * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.22e+120) tmp = Float64(x + Float64(z * Float64(y * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.22e+120) tmp = x + (z * (y * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.22e+120], N[(x + N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.22 \cdot 10^{+120}:\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.22e120Initial program 97.3%
Taylor expanded in x around 0 21.4%
associate-*r*21.3%
*-commutative21.3%
associate-/r*21.3%
div-sub21.3%
rec-exp21.3%
rec-exp21.3%
tanh-def-a78.3%
associate-*l*79.2%
Simplified79.2%
if 1.22e120 < y Initial program 84.1%
Taylor expanded in y around inf 91.7%
Final simplification80.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1350000000.0) x (if (<= y 1.05e+188) (- x (* z x)) (+ x (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1350000000.0) {
tmp = x;
} else if (y <= 1.05e+188) {
tmp = x - (z * x);
} else {
tmp = x + (z * t);
}
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 <= 1350000000.0d0) then
tmp = x
else if (y <= 1.05d+188) then
tmp = x - (z * x)
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1350000000.0) {
tmp = x;
} else if (y <= 1.05e+188) {
tmp = x - (z * x);
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1350000000.0: tmp = x elif y <= 1.05e+188: tmp = x - (z * x) else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1350000000.0) tmp = x; elseif (y <= 1.05e+188) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1350000000.0) tmp = x; elseif (y <= 1.05e+188) tmp = x - (z * x); else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1350000000.0], x, If[LessEqual[y, 1.05e+188], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1350000000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+188}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.35e9Initial program 97.1%
+-commutative97.1%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Taylor expanded in y around 0 64.5%
if 1.35e9 < y < 1.04999999999999993e188Initial program 94.9%
Taylor expanded in x around 0 80.6%
Taylor expanded in t around 0 66.0%
Taylor expanded in t around 0 58.5%
mul-1-neg58.5%
distribute-frac-neg58.5%
Simplified58.5%
Taylor expanded in x around 0 61.1%
mul-1-neg61.1%
distribute-rgt-in61.1%
*-lft-identity61.1%
cancel-sign-sub-inv61.1%
*-commutative61.1%
Simplified61.1%
if 1.04999999999999993e188 < y Initial program 77.8%
Taylor expanded in x around 0 31.0%
associate-*r*30.1%
*-commutative30.1%
associate-/r*30.1%
div-sub30.1%
rec-exp30.1%
rec-exp30.1%
tanh-def-a66.2%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in y around inf 78.2%
+-commutative78.2%
Simplified78.2%
Final simplification64.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.25e-35) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e-35) {
tmp = x;
} else {
tmp = x + (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 <= 1.25d-35) then
tmp = x
else
tmp = x + (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 <= 1.25e-35) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.25e-35: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.25e-35) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.25e-35) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.25e-35], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{-35}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.24999999999999991e-35Initial program 96.9%
+-commutative96.9%
associate-*l*98.0%
fma-def98.0%
Simplified98.0%
Taylor expanded in y around 0 65.3%
if 1.24999999999999991e-35 < y Initial program 91.5%
Taylor expanded in y around inf 73.9%
Final simplification67.6%
(FPCore (x y z t) :precision binary64 (if (<= x -2.85e-117) x (if (<= x 2.5e-227) (* z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.85e-117) {
tmp = x;
} else if (x <= 2.5e-227) {
tmp = z * t;
} 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 (x <= (-2.85d-117)) then
tmp = x
else if (x <= 2.5d-227) then
tmp = z * t
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.85e-117) {
tmp = x;
} else if (x <= 2.5e-227) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.85e-117: tmp = x elif x <= 2.5e-227: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.85e-117) tmp = x; elseif (x <= 2.5e-227) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.85e-117) tmp = x; elseif (x <= 2.5e-227) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.85e-117], x, If[LessEqual[x, 2.5e-227], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.85 \cdot 10^{-117}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-227}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.85e-117 or 2.4999999999999998e-227 < x Initial program 97.0%
+-commutative97.0%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around 0 69.1%
if -2.85e-117 < x < 2.4999999999999998e-227Initial program 90.3%
Taylor expanded in x around 0 9.6%
associate-*r*9.4%
*-commutative9.4%
associate-/r*9.4%
div-sub9.4%
rec-exp9.4%
rec-exp9.4%
tanh-def-a74.2%
associate-*l*77.3%
Simplified77.3%
Taylor expanded in y around inf 49.5%
+-commutative49.5%
Simplified49.5%
Taylor expanded in t around inf 40.2%
*-commutative40.2%
Simplified40.2%
Final simplification62.3%
(FPCore (x y z t) :precision binary64 (if (<= y 4.4e+67) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.4e+67) {
tmp = x;
} else {
tmp = x + (z * t);
}
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 <= 4.4d+67) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.4e+67) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.4e+67: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.4e+67) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.4e+67) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.4e+67], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{+67}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 4.4e67Initial program 97.2%
+-commutative97.2%
associate-*l*98.2%
fma-def98.2%
Simplified98.2%
Taylor expanded in y around 0 62.9%
if 4.4e67 < y Initial program 88.2%
Taylor expanded in x around 0 31.6%
associate-*r*31.1%
*-commutative31.1%
associate-/r*31.1%
div-sub31.1%
rec-exp31.2%
rec-exp31.2%
tanh-def-a66.2%
associate-*l*72.2%
Simplified72.2%
Taylor expanded in y around inf 62.8%
+-commutative62.8%
Simplified62.8%
Final simplification62.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 95.4%
+-commutative95.4%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Taylor expanded in y around 0 57.9%
Final simplification57.9%
(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 2023297
(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))))))