
(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 9 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 2e+183) (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2e+183) {
tmp = fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2e+183) tmp = fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2e+183], N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $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^{+183}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.99999999999999989e183Initial program 93.3%
+-commutative93.3%
*-commutative93.3%
associate-*l*97.0%
fma-def97.0%
Simplified97.0%
if 1.99999999999999989e183 < y Initial program 66.6%
associate-*l*87.7%
Simplified87.7%
Taylor expanded in y around inf 96.6%
Final simplification97.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.1e+184) (+ 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 <= 1.1e+184) {
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 <= 1.1d+184) 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 <= 1.1e+184) {
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 <= 1.1e+184: 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 <= 1.1e+184) 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 <= 1.1e+184) 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, 1.1e+184], 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 1.1 \cdot 10^{+184}:\\
\;\;\;\;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.1e184Initial program 93.3%
associate-*l*97.0%
Simplified97.0%
if 1.1e184 < y Initial program 66.6%
associate-*l*87.7%
Simplified87.7%
Taylor expanded in y around inf 96.6%
Final simplification96.9%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (or (<= t -5e+106) (not (<= t 8.2e-70))) (+ x (* (tanh (/ t y)) (* y z))) (fma z (- t (* y (tanh (/ x y)))) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -5e+106) || !(t <= 8.2e-70)) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = fma(z, (t - (y * tanh((x / y)))), x);
}
return tmp;
}
y = abs(y) function code(x, y, z, t) tmp = 0.0 if ((t <= -5e+106) || !(t <= 8.2e-70)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = fma(z, Float64(t - Float64(y * tanh(Float64(x / y)))), x); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[Or[LessEqual[t, -5e+106], N[Not[LessEqual[t, 8.2e-70]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - N[(y * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5 \cdot 10^{+106} \lor \neg \left(t \leq 8.2 \cdot 10^{-70}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - y \cdot \tanh \left(\frac{x}{y}\right), x\right)\\
\end{array}
\end{array}
if t < -4.9999999999999998e106 or 8.19999999999999955e-70 < t Initial program 99.2%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in x around 0 7.8%
*-commutative7.8%
associate-/r*7.7%
div-sub7.8%
rec-exp7.8%
rec-exp7.8%
Simplified85.8%
if -4.9999999999999998e106 < t < 8.19999999999999955e-70Initial program 83.4%
+-commutative83.4%
*-commutative83.4%
associate-*l*92.9%
fma-def92.9%
Simplified92.9%
Taylor expanded in t around 0 84.8%
Taylor expanded in t around -inf 31.3%
+-commutative31.3%
mul-1-neg31.3%
unsub-neg31.3%
associate-/r*31.3%
Simplified86.6%
Final simplification86.3%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.1e+183) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+183) {
tmp = x + (tanh((t / y)) * (y * z));
} 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.1d+183) then
tmp = x + (tanh((t / y)) * (y * z))
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.1e+183) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.1e+183: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.1e+183) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); 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.1e+183) tmp = x + (tanh((t / y)) * (y * z)); 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.1e+183], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $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 1.1 \cdot 10^{+183}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.09999999999999995e183Initial program 93.3%
associate-*l*97.0%
Simplified97.0%
Taylor expanded in x around 0 25.2%
*-commutative25.2%
associate-/r*25.2%
div-sub25.2%
rec-exp25.2%
rec-exp25.2%
Simplified75.2%
if 1.09999999999999995e183 < y Initial program 66.6%
associate-*l*87.7%
Simplified87.7%
Taylor expanded in y around inf 96.6%
Final simplification77.4%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(if (<= y 15000.0)
x
(if (or (<= y 1.06e+243) (not (<= y 3.1e+290)))
(+ x (* z t))
(- x (* z x)))))y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 15000.0) {
tmp = x;
} else if ((y <= 1.06e+243) || !(y <= 3.1e+290)) {
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 <= 15000.0d0) then
tmp = x
else if ((y <= 1.06d+243) .or. (.not. (y <= 3.1d+290))) 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 <= 15000.0) {
tmp = x;
} else if ((y <= 1.06e+243) || !(y <= 3.1e+290)) {
tmp = x + (z * t);
} else {
tmp = x - (z * x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 15000.0: tmp = x elif (y <= 1.06e+243) or not (y <= 3.1e+290): 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 <= 15000.0) tmp = x; elseif ((y <= 1.06e+243) || !(y <= 3.1e+290)) 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 <= 15000.0) tmp = x; elseif ((y <= 1.06e+243) || ~((y <= 3.1e+290))) 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, 15000.0], x, If[Or[LessEqual[y, 1.06e+243], N[Not[LessEqual[y, 3.1e+290]], $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 15000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.06 \cdot 10^{+243} \lor \neg \left(y \leq 3.1 \cdot 10^{+290}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < 15000Initial program 93.5%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in x around inf 65.9%
if 15000 < y < 1.06e243 or 3.1000000000000001e290 < y Initial program 83.5%
associate-*l*92.1%
Simplified92.1%
Taylor expanded in x around 0 33.4%
*-commutative33.4%
associate-/r*33.4%
div-sub33.4%
rec-exp33.4%
rec-exp33.4%
Simplified63.9%
Taylor expanded in y around inf 59.5%
if 1.06e243 < y < 3.1000000000000001e290Initial program 71.3%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in y around inf 90.9%
Taylor expanded in x around inf 71.3%
distribute-rgt1-in71.3%
associate-*r*71.3%
mul-1-neg71.3%
unsub-neg71.3%
Simplified71.3%
Final simplification64.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 7200.0) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7200.0) {
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 <= 7200.0d0) 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 <= 7200.0) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 7200.0: tmp = x else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 7200.0) 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 <= 7200.0) 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, 7200.0], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7200:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7200Initial program 93.5%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in x around inf 65.9%
if 7200 < y Initial program 81.6%
associate-*l*93.3%
Simplified93.3%
Taylor expanded in y around inf 81.3%
Final simplification69.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= x -3.5e-175) x (if (<= x 2.4e-280) (* z t) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -3.5e-175) {
tmp = x;
} else if (x <= 2.4e-280) {
tmp = z * t;
} else {
tmp = 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 (x <= (-3.5d-175)) then
tmp = x
else if (x <= 2.4d-280) then
tmp = z * t
else
tmp = 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 (x <= -3.5e-175) {
tmp = x;
} else if (x <= 2.4e-280) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if x <= -3.5e-175: tmp = x elif x <= 2.4e-280: tmp = z * t else: tmp = x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (x <= -3.5e-175) tmp = x; elseif (x <= 2.4e-280) tmp = Float64(z * t); else tmp = x; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -3.5e-175) tmp = x; elseif (x <= 2.4e-280) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[x, -3.5e-175], x, If[LessEqual[x, 2.4e-280], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-175}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-280}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.49999999999999999e-175 or 2.3999999999999998e-280 < x Initial program 92.1%
associate-*l*96.1%
Simplified96.1%
Taylor expanded in x around inf 64.3%
if -3.49999999999999999e-175 < x < 2.3999999999999998e-280Initial program 68.3%
associate-*l*94.6%
Simplified94.6%
Taylor expanded in x around 0 13.1%
*-commutative13.1%
associate-/r*13.1%
div-sub13.1%
rec-exp13.1%
rec-exp13.1%
Simplified68.3%
Taylor expanded in y around inf 78.7%
Taylor expanded in t around inf 68.4%
Final simplification64.6%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 26000.0) x (+ x (* z t))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 26000.0) {
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 <= 26000.0d0) 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 <= 26000.0) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 26000.0: tmp = x else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 26000.0) 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 <= 26000.0) 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, 26000.0], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 26000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 26000Initial program 93.5%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in x around inf 65.9%
if 26000 < y Initial program 81.6%
associate-*l*93.3%
Simplified93.3%
Taylor expanded in x around 0 34.7%
*-commutative34.7%
associate-/r*34.7%
div-sub34.7%
rec-exp34.7%
rec-exp34.7%
Simplified64.9%
Taylor expanded in y around inf 59.9%
Final simplification64.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 90.5%
associate-*l*96.0%
Simplified96.0%
Taylor expanded in x around inf 61.2%
Final simplification61.2%
(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 2023202
(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))))))