
(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 (+ x (* z (* y (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (z * (y * (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 + (z * (y * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (z * (y * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (z * (y * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(z * Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (z * (y * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
Initial program 96.5%
Taylor expanded in y around 0 18.3%
*-commutative18.3%
associate-*l*18.3%
Simplified98.5%
Final simplification98.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.32e-77) (not (<= x 2.8e+107))) (- x (* y (* z (tanh (/ x y))))) (+ x (* z (* y (tanh (/ t y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.32e-77) || !(x <= 2.8e+107)) {
tmp = x - (y * (z * tanh((x / y))));
} else {
tmp = x + (z * (y * tanh((t / 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 ((x <= (-1.32d-77)) .or. (.not. (x <= 2.8d+107))) then
tmp = x - (y * (z * tanh((x / y))))
else
tmp = x + (z * (y * tanh((t / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.32e-77) || !(x <= 2.8e+107)) {
tmp = x - (y * (z * Math.tanh((x / y))));
} else {
tmp = x + (z * (y * Math.tanh((t / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.32e-77) or not (x <= 2.8e+107): tmp = x - (y * (z * math.tanh((x / y)))) else: tmp = x + (z * (y * math.tanh((t / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.32e-77) || !(x <= 2.8e+107)) tmp = Float64(x - Float64(y * Float64(z * tanh(Float64(x / y))))); else tmp = Float64(x + Float64(z * Float64(y * tanh(Float64(t / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.32e-77) || ~((x <= 2.8e+107))) tmp = x - (y * (z * tanh((x / y)))); else tmp = x + (z * (y * tanh((t / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.32e-77], N[Not[LessEqual[x, 2.8e+107]], $MachinePrecision]], N[(x - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.32 \cdot 10^{-77} \lor \neg \left(x \leq 2.8 \cdot 10^{+107}\right):\\
\;\;\;\;x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\end{array}
\end{array}
if x < -1.31999999999999993e-77 or 2.79999999999999985e107 < x Initial program 96.5%
Taylor expanded in t around 0 17.6%
sub-neg17.6%
+-commutative17.6%
neg-sub017.6%
associate--r-17.6%
Simplified89.6%
if -1.31999999999999993e-77 < x < 2.79999999999999985e107Initial program 96.6%
Taylor expanded in y around 0 21.8%
*-commutative21.8%
associate-*l*21.8%
Simplified97.5%
Taylor expanded in x around 0 22.9%
associate-/r*23.0%
div-sub22.9%
rec-exp22.9%
rec-exp22.9%
tanh-def-a88.3%
Simplified88.3%
Final simplification89.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (tanh (/ t y))))) (if (<= y 1.9e+39) (+ x (* z t_1)) (+ x (* z (- t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = y * tanh((t / y));
double tmp;
if (y <= 1.9e+39) {
tmp = x + (z * t_1);
} else {
tmp = x + (z * (t_1 - 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 = y * tanh((t / y))
if (y <= 1.9d+39) then
tmp = x + (z * t_1)
else
tmp = x + (z * (t_1 - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * Math.tanh((t / y));
double tmp;
if (y <= 1.9e+39) {
tmp = x + (z * t_1);
} else {
tmp = x + (z * (t_1 - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = y * math.tanh((t / y)) tmp = 0 if y <= 1.9e+39: tmp = x + (z * t_1) else: tmp = x + (z * (t_1 - x)) return tmp
function code(x, y, z, t) t_1 = Float64(y * tanh(Float64(t / y))) tmp = 0.0 if (y <= 1.9e+39) tmp = Float64(x + Float64(z * t_1)); else tmp = Float64(x + Float64(z * Float64(t_1 - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * tanh((t / y)); tmp = 0.0; if (y <= 1.9e+39) tmp = x + (z * t_1); else tmp = x + (z * (t_1 - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.9e+39], N[(x + N[(z * t$95$1), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t$95$1 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 1.9 \cdot 10^{+39}:\\
\;\;\;\;x + z \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t_1 - x\right)\\
\end{array}
\end{array}
if y < 1.8999999999999999e39Initial program 97.5%
Taylor expanded in y around 0 14.5%
*-commutative14.5%
associate-*l*14.5%
Simplified99.0%
Taylor expanded in x around 0 25.5%
associate-/r*25.5%
div-sub25.5%
rec-exp25.5%
rec-exp25.5%
tanh-def-a80.4%
Simplified80.4%
if 1.8999999999999999e39 < y Initial program 92.7%
Taylor expanded in x around 0 66.7%
+-commutative66.7%
Simplified98.1%
Final simplification84.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.12e+136) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.12e+136) {
tmp = x + (y * (z * 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.12d+136) then
tmp = x + (y * (z * 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.12e+136) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.12e+136: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.12e+136) tmp = Float64(x + Float64(y * Float64(z * 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.12e+136) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.12e+136], 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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{+136}:\\
\;\;\;\;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 < 1.12000000000000001e136Initial program 97.7%
Taylor expanded in x around 0 25.9%
associate-/r*25.9%
div-sub25.9%
rec-exp25.9%
rec-exp25.9%
tanh-def-a80.6%
Simplified80.6%
if 1.12000000000000001e136 < y Initial program 89.3%
Taylor expanded in y around inf 93.7%
Final simplification82.4%
(FPCore (x y z t) :precision binary64 (if (<= y 9e+134) (+ x (* z (* y (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9e+134) {
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 <= 9d+134) 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 <= 9e+134) {
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 <= 9e+134: 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 <= 9e+134) 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 <= 9e+134) 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, 9e+134], 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 9 \cdot 10^{+134}:\\
\;\;\;\;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 < 8.9999999999999995e134Initial program 97.7%
Taylor expanded in y around 0 14.3%
*-commutative14.3%
associate-*l*14.3%
Simplified99.1%
Taylor expanded in x around 0 25.9%
associate-/r*25.9%
div-sub25.9%
rec-exp25.9%
rec-exp25.9%
tanh-def-a81.0%
Simplified81.0%
if 8.9999999999999995e134 < y Initial program 89.3%
Taylor expanded in y around inf 93.7%
Final simplification82.8%
(FPCore (x y z t) :precision binary64 (if (<= y 7.8e+134) (+ x (* (tanh (/ t y)) (* z y))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.8e+134) {
tmp = x + (tanh((t / y)) * (z * 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 <= 7.8d+134) then
tmp = x + (tanh((t / y)) * (z * 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 <= 7.8e+134) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7.8e+134: tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7.8e+134) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * 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 <= 7.8e+134) tmp = x + (tanh((t / y)) * (z * y)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.8e+134], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.8 \cdot 10^{+134}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7.79999999999999967e134Initial program 97.7%
Taylor expanded in x around 0 25.9%
associate-*r*25.7%
associate-/r*25.7%
div-sub25.7%
rec-exp25.7%
rec-exp25.7%
tanh-def-a82.2%
*-commutative82.2%
Simplified82.2%
if 7.79999999999999967e134 < y Initial program 89.3%
Taylor expanded in y around inf 93.7%
Final simplification83.8%
(FPCore (x y z t) :precision binary64 (if (<= y 8e+38) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8e+38) {
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 <= 8d+38) 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 <= 8e+38) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8e+38: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8e+38) 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 <= 8e+38) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8e+38], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7.99999999999999982e38Initial program 97.5%
Taylor expanded in y around inf 51.9%
Taylor expanded in z around 0 62.5%
if 7.99999999999999982e38 < y Initial program 92.7%
Taylor expanded in y around inf 87.0%
Final simplification67.5%
(FPCore (x y z t) :precision binary64 (if (<= y 8.5e+95) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.5e+95) {
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 <= 8.5d+95) 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 <= 8.5e+95) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.5e+95: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.5e+95) 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 <= 8.5e+95) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.5e+95], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{+95}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 8.5000000000000002e95Initial program 97.7%
Taylor expanded in y around inf 52.2%
Taylor expanded in z around 0 61.3%
if 8.5000000000000002e95 < y Initial program 90.8%
Taylor expanded in y around inf 94.6%
Taylor expanded in t around inf 76.1%
Final simplification63.7%
(FPCore (x y z t) :precision binary64 (if (<= y 9.5e+38) x (- x (* x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9.5e+38) {
tmp = x;
} else {
tmp = x - (x * z);
}
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 <= 9.5d+38) then
tmp = x
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9.5e+38) {
tmp = x;
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 9.5e+38: tmp = x else: tmp = x - (x * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 9.5e+38) tmp = x; else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 9.5e+38) tmp = x; else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 9.5e+38], x, N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < 9.4999999999999995e38Initial program 97.5%
Taylor expanded in y around inf 51.9%
Taylor expanded in z around 0 62.5%
if 9.4999999999999995e38 < y Initial program 92.7%
Taylor expanded in y around inf 87.0%
Taylor expanded in x around inf 72.8%
distribute-lft-in72.8%
*-rgt-identity72.8%
mul-1-neg72.8%
distribute-rgt-neg-in72.8%
unsub-neg72.8%
Simplified72.8%
Final simplification64.6%
(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 96.5%
Taylor expanded in y around inf 59.2%
Taylor expanded in z around 0 58.9%
Final simplification58.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 2023275
(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))))))