double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+188) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
} else {
tmp = (z * t) + (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
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end 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.5d+188) then
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
else
tmp = (z * t) + (x - (x * z))
end if
code = tmp
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))));
}
↓
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e+188) {
tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
} else {
tmp = (z * t) + (x - (x * z));
}
return tmp;
}
def code(x, y, z, t):
return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
↓
def code(x, y, z, t):
tmp = 0
if y <= 3.5e+188:
tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
else:
tmp = (z * t) + (x - (x * z))
return tmp
function code(x, y, z, t)
return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))
end
↓
function code(x, y, z, t)
tmp = 0.0
if (y <= 3.5e+188)
tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))));
else
tmp = Float64(Float64(z * t) + Float64(x - Float64(x * z)));
end
return tmp
end
function tmp = code(x, y, z, t)
tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
end
↓
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= 3.5e+188)
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
else
tmp = (z * t) + (x - (x * z));
end
tmp_2 = tmp;
end
(+.f64 x (*.f64 y (*.f64 z (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 0 points increase in error, 0 points decrease in error
(+.f64 x (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 18 points increase in error, 7 points decrease in error
(+.f64 x (*.f64 y (*.f64 z (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 0 points increase in error, 0 points decrease in error
(+.f64 x (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 18 points increase in error, 7 points decrease in error
Taylor expanded in y around inf 11.2
\[\leadsto x + y \cdot \color{blue}{\frac{\left(t - x\right) \cdot z}{y}}
\]
Simplified14.2
\[\leadsto x + y \cdot \color{blue}{\frac{t - x}{\frac{y}{z}}}
\]
Proof
(/.f64 (-.f64 t x) (/.f64 y z)): 0 points increase in error, 0 points decrease in error
(Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (-.f64 t x) z) y)): 43 points increase in error, 33 points decrease in error
Applied egg-rr11.4
\[\leadsto x + y \cdot \color{blue}{\left(\frac{1}{y} \cdot \frac{t - x}{\frac{1}{z}}\right)}
\]
Applied egg-rr5.8
\[\leadsto x + \color{blue}{\frac{t - x}{\frac{1}{z}}}
\]
Applied egg-rr5.6
\[\leadsto \color{blue}{t \cdot z - \left(x \cdot z - x\right)}
\]
Recombined 2 regimes into one program.
Final simplification1.6
\[\leadsto \begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+188}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t + \left(x - x \cdot z\right)\\
\end{array}
\]
herbie shell --seed 2022337
(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))))))