class ExponentialFunction:Function, ICloneable
    {
        private double _a;
        private double _b;
        public ExponentialFunction(List<double> valuesOfX, List<double> valuesOfY)
        {
            
            CountCoefficients(valuesOfX, valuesOfY);
        }
        public void CountCoefficients(List<double> valuesOfX, List<double> valuesOfY)
        {
            int n = valuesOfX.Count;
            double sumOfX = 0;
            double sumOfLnY = 0;
            double sumOfXLnY = 0;
            double sumOfXX = 0;
            foreach (double x in valuesOfX) sumOfX += x;
            foreach (double y in valuesOfY)
            {
                if (y <= 0) throw new ArgumentException("Значения y должны соответствовать области значений функции (y > 0)");
                sumOfLnY += Math.Log(y);
            }
            foreach (double x in valuesOfX) sumOfXX += x * x;
            for (int i = 0; i < n; i++) sumOfXLnY += valuesOfX[i] * Math.Log(valuesOfY[i]);
            _b = Math.Exp((n * sumOfXLnY - sumOfLnY * sumOfX) / (n * sumOfXX - sumOfX * sumOfX));
            _a = Math.Exp(sumOfLnY / n - Math.Log(_b) / n * sumOfX);
        }
        public double ValueInX(double x)
        {
            return _a * Math.Pow(_b, x);
        }
        public string FunctionString
        {
            get { return "y=" + _a + "*" + _b + "^x" ; }
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }