public void EExponential(double power, int accuracy)
        {
            double accuracity = Math.Pow(10, accuracy);

            var res = TaylorApproxer.EExponential(power, accuracy);

            Assert.AreEqual(Math.Truncate(accuracity * Math.Pow(Math.E, power)) / accuracity,
                            Math.Truncate(accuracity * res) / accuracity);
        }
        public void CosineHyper(double x, int accuracy)
        {
            double accuracity = Math.Pow(10, accuracy);

            var res = TaylorApproxer.CosineHyper(x, accuracy);

            Assert.AreEqual(Math.Truncate(accuracity * Math.Cosh(Helper.DegreeToRadian(x))) / accuracity,
                            Math.Truncate(accuracity * res) / accuracity);
        }
        public void Exponential(double x, double power, int accuracy)
        {
            double accuracity = Math.Pow(10, accuracy);

            var res = TaylorApproxer.Exponential(x, power, accuracy);

            Assert.AreEqual(Math.Truncate(accuracity * Math.Pow(x, power)) / accuracity,
                            Math.Truncate(accuracity * res) / accuracity);
            Console.WriteLine(res);
        }
        public void Arccos(double x, int accuracy)
        {
            double accuracity = Math.Pow(10, accuracy);

            var res = TaylorApproxer.Arccosinus(x, accuracy);

            Assert.AreEqual(Math.Truncate(accuracity * Math.Acos(Helper.DegreeToRadian(x))) / accuracity,
                            Math.Truncate(accuracity * res) / accuracity);
            Console.WriteLine(res);
        }
        public void Logarithm(double x, int accuracy)
        {
            double accuracity = Math.Pow(10, accuracy);

            var res = TaylorApproxer.Logarithm(x, accuracy);

            Assert.AreEqual(Math.Truncate(accuracity * Math.Log(x)) / accuracity,
                            Math.Truncate(accuracity * res) / accuracity);
            Console.WriteLine(res);
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (listBox1.SelectedIndex)
            {
            case 0:     // Cosh
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.CosineHyper(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 1:     // Sinh
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.SineHyper(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 2:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Sine(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 3:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Cosine(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 4:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Tangent(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 5:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Arccosinus(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 6:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Arcsinus(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 7:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Arctangent(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 8:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.EExponential(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 9:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Logarithm(Double.Parse(textBox1.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 10:
            {
                if (!string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = HighPrecisionPi.GetPi(Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 11:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Power(Double.Parse(textBox1.Text), Double.Parse(textBox2.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }

            case 12:
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text) && !string.IsNullOrWhiteSpace(textBox2.Text) && !string.IsNullOrWhiteSpace(textBox3.Text))
                {
                    textBox4.Text = TaylorApproxer.Exponential(Double.Parse(textBox1.Text), Double.Parse(textBox2.Text), Int32.Parse(textBox3.Text)).ToString();
                }
                break;
            }
            }
        }