@name Robotboy655's Expression One: Advanced Smoother
@inputs Target Speed Acceleration
@outputs Value Active
@persist Rate 

# Activate when target has been set
if(~Target){Active = 1}

# Main computation loop
if(first() | clk()){
# Precomputation of inputs
    if(!Acceleration){Acceleration = Speed * 50 * 2}
    AccLength = Speed^2 / Acceleration / 2
    AccRate = min(Speed, Acceleration / 50)
# Precomputation of variables
    Distance = Target - Value
    Direction = Distance >= 0 ? 1 : -1
# Calculate ideal speed modifier
    IdealRate = Speed * Direction
    if(abs(Distance) <= AccLength){
        IdealRate *= sqrt(abs(Distance - Rate / 50) / AccLength)}
# Calculate final speed for iteration
    Rate += clamp(IdealRate - Rate, -Acceleration / 50, Acceleration / 50)
    Value += Rate / 50
# Check if value has reached target
    Active = abs(Rate) > AccRate
                | abs(Distance) > AccRate / 50
    if(!Active){Rate = 0 
Value = Target}}

# Schedule the main loop if active
if(Active){interval(20)}
