import numpy


class InitialDataControlSine:
    def __init__(self, coefficients):
        self.coefficients = coefficients

    def __call__(self, x):
        u = numpy.zeros_like(x)

        for k, coefficient in enumerate(self.coefficients):
            u += coefficient  * numpy.sin(k * numpy.pi * x)

        return u

    def exact_solution(self, x, t, q=1):
        return sum(coefficient * numpy.exp(-q * (k * numpy.pi) ** 2 * t) * numpy.sin(
            k * numpy.pi * x) for k, coefficient in enumerate(self.coefficients))

[((9, 12, 9, 31), 'numpy.zeros_like', 'numpy.zeros_like', ({(9, 29, 9, 30): 'x'}, {}), '(x)', False, 'import numpy\n'), ((12, 32, 12, 59), 'numpy.sin', 'numpy.sin', ({(12, 42, 12, 58): '(k * numpy.pi * x)'}, {}), '(k * numpy.pi * x)', False, 'import numpy\n'), ((17, 75, 18, 29), 'numpy.sin', 'numpy.sin', ({(18, 12, 18, 28): '(k * numpy.pi * x)'}, {}), '(k * numpy.pi * x)', False, 'import numpy\n'), ((17, 33, 17, 72), 'numpy.exp', 'numpy.exp', ({(17, 43, 17, 71): '(-q * (k * numpy.pi) ** 2 * t)'}, {}), '(-q * (k * numpy.pi) ** 2 * t)', False, 'import numpy\n')]