import math


def elastic_easeinout(pos):
    """
    Easing function for animations: Elastic Ease In & Out
    """
    if pos < 0.5:
        return 0.5 * math.sin(13 * math.pi * pos) * math.pow(2, 10 * ((2 * pos) - 1))
    return 0.5 * (
        math.sin(-13 * math.pi / 2 * ((2 * pos - 1) + 1)) * pow(2, -10 * (2 * pos - 1))
        + 2
    )