LoginSignup
2
2

More than 5 years have passed since last update.

三次方程式の実数解と虚数解の割合

Last updated at Posted at 2017-10-18
ax^3 + bx^2 + cx + d = 0

の実係数a,b,c,dを乱数(-2,147,483,648 ~ 2,147,483,647)で発生させ
実数解と虚数解の割合を計算しました。

10,000,000回計算した結果
実数解:2179554(21.79554%)
虚数解:7820446(78.20446%)
三重解:0(0%)

なぜ、この割合なのかを数学的に証明できたらと思っています。

以下にソースコードの一部を掲載します。

private void abcd_r_3()
        {
            double a;
            double b;
            double c;
            double d;
            double dd;

            byte[] bs = new byte[4];
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

            int m = 0; //重解 multiple root
            int r = 0;
            int i = 0;

            double total = 10000000;

            for (int x = 0; x < total; x++)
            {
                do
                {
                    rng.GetBytes(bs);
                    //Int32に変換する
                    a = BitConverter.ToInt32(bs, 0);
                    //a = -1;
                } while (a == 0);

                rng.GetBytes(bs);
                //Int32に変換する
                b = BitConverter.ToInt32(bs, 0);

                rng.GetBytes(bs);
                //Int32に変換する
                c = BitConverter.ToInt32(bs, 0);

                rng.GetBytes(bs);
                //Int32に変換する
                d = BitConverter.ToInt32(bs, 0);

                dd = -4 * a * c * c * c - 27 * a * a * d * d + b * b * c * c + 18 * a * b * c * d - 4 * b * b * b * d;

                if (dd == 0)
                {
                    m++;
                }
                else if (dd > 0)
                {
                    r++;
                }
                else
                {
                    i++;
                }
            }


            double m_p = m * 100 / total;
            double r_p = r * 100 / total;
            double i_p = i * 100 / total;

            Invoke(new dldl(delegate
            {
                textBox1.AppendText("実数解:" + r.ToString() + "(" + r_p.ToString() + "%)" +
                                    "虚数解:" + i.ToString() + "(" + i_p.ToString() + "%)" +
                                    "三重解:" + m.ToString() + "(" + m_p.ToString() + "%)" + Environment.NewLine);
                button3.Enabled = true;
            }));
        }
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2