예제 #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            sbeta = "";
            LoiGiai loigiai = new LoiGiai();

            for (int i = 1; i <= 19; i++)
            {
                lg[i] = new Label();
            }
            for (int i = 1; i <= 19; i++)
            {
                lg[i].Font     = new Font("VNF-Comic Sans", 12);
                lg[i].AutoSize = true;
            }
            if (a * a + b * b < Math.Round(c * c, 3))
            {
                lg[1].Text     = "Phương trình vô nghiệm vì";
                lg[1].Location = new Point(30, 30);

                PictureBox ptb = new PictureBox();
                ptb.BackgroundImage = Properties.Resources.abc;
                ptb.Location        = new Point(220, 28);
                ptb.Size            = new Size(110, 28);
                loigiai.Controls.Add(ptb);
            }
            else
            {
                if (Math.Round(a, 3) == 1)
                {
                    soa = "";
                }
                else
                {
                    soa = Math.Round(a, 3).ToString();
                }
                if (b > 0)
                {
                    if (Math.Round(b, 3) == 1)
                    {
                        sob = "+ ";
                    }
                    else
                    {
                        sob = "+ " + Math.Round(b, 3).ToString();
                    }
                }
                if (b < 0)
                {
                    if (Math.Round(b, 3) == -1)
                    {
                        sob = "- ";
                    }
                    else
                    {
                        sob = "- " + Math.Round(-b, 3) + "";
                    }
                }
                if (Math.Round(m, 3) == 1)
                {
                    som = "";
                }
                else
                {
                    som = Math.Round(m, 3).ToString();
                }
                if (n > 0)
                {
                    son = "+ " + Math.Round(n, 3);
                }
                if (n < 0)
                {
                    son = "- " + Math.Round(-n, 3);
                }
                soc = Math.Round(c, 3) + "";

                lg[3].Text = soa + "sin(" + som + "x " + son + ") " +
                             sob + "cos(" + som + "x " + son + ") = " +
                             soc + "  (*)";
                lg[3].Location = new Point(20, 20);

                lg[1].Text = "Vì";

                PictureBox ptb1 = new PictureBox();
                ptb1.Image = Properties.Resources.ab;
                ptb1.Size  = new Size(69, 28);
                loigiai.Controls.Add(ptb1);

                lg[2].Text = " = " + a * a + " + " + b * b + " = " + Math.Round(a * a + b * b, 5) + " ≠ 0";

                lg[1].Location = new Point(30, 50);
                ptb1.Location  = new Point(50, 50);
                lg[2].Location = new Point(115, 50);

                loigiai.Controls.Add(ptb1);

                lg[4].Text = "(*) <=>  " + Math.Round(a / canab, 3) + "sin(" + som + "x " + son + ") + " +
                             Math.Round(b / canab, 3) + "cos(" + som + "x " + son + ") = " +
                             Math.Round(c / canab, 3);
                lg[4].Location = new Point(30, 80);

                double y = beta * 180 / Math.PI;
                int    y1;
                if (int.TryParse(Math.Round(y, 3).ToString(), out y1))
                {
                    if (giai.timthay(y1))
                    {
                        sbeta = "" + giai.gdb[y1];
                    }
                    else if (giai.timthay(-y1))
                    {
                        sbeta = "" + giai.gdb[-y1];
                    }
                    else
                    {
                        sbeta = Math.Round(beta, 3).ToString();
                    }
                }
                else
                {
                    sbeta = Math.Round(beta, 3).ToString();
                }

                lg[5].Text = "<=>  cos(" + sbeta + ")sin(" + som + "x " + son + ") + " +
                             "sin(" + sbeta + ")cos(" + som + "x " + son +
                             ") = " + Math.Round(c / canab, 3);

                lg[6].Text = "<=>  sin(" + som + "x " + son + " + " + sbeta + ") = " + Math.Round(c / canab, 3);

                //lg[7].Text = "<=>  sin(" + som + "x " + son + " + " + sbeta + ") = sin(" + arcsinc() + ")";

                lg[5].Location = new Point(55, 110);
                lg[6].Location = new Point(55, 140);
                //lg[7].Location = new Point(55, 170);

                if (Math.Round(c / canab, 5) == 1 || Math.Round(c / canab, 5) == -1 || Math.Round(c, 5) == 0)
                {
                    lg[8].Text     = "<=> " + som + "x " + son + " + " + sbeta + " = " + arcsinc1() + " + k2π";
                    lg[8].Location = new Point(55, 170);

                    lg[9].Text     = "<=> " + ngh1;
                    lg[9].Location = new Point(55, 200);
                }
                else
                {
                    lg[8].Text = "<=>";
                    PictureBox ptb2 = new PictureBox();
                    ptb2.Image = Properties.Resources.daungoac;
                    ptb2.Size  = new Size(27, 58);
                    loigiai.Controls.Add(ptb2);

                    lg[8].Location = new Point(55, 185);
                    ptb2.Location  = new Point(90, 170);

                    lg[9].Text  = som + "x " + son + " + " + sbeta + " = " + arcsinc1() + "+ k2π";
                    lg[10].Text = som + "x " + son + " + " + sbeta + " = π - " + arcsinc1() + "+ k2π";

                    lg[9].Location  = new Point(120, 170);
                    lg[10].Location = new Point(120, 200);

                    lg[11].Text = kq[1];
                    lg[12].Text = kq[2];

                    lg[13].Text = "<=>";

                    PictureBox ptb3 = new PictureBox();
                    ptb3.Image    = Properties.Resources.daungoac;
                    ptb3.Size     = new Size(27, 58);
                    ptb3.Location = new Point(90, 230);
                    loigiai.Controls.Add(ptb3);

                    lg[13].Location = new Point(55, 245);

                    lg[11].Location = new Point(120, 230);
                    lg[12].Location = new Point(120, 260);
                }
            }

            Button button3 = new Button();

            button3.Text     = "Hướng dẫn giải tổng quát";
            button3.Font     = button1.Font;
            button3.Size     = new Size(200, 40);
            button3.Location = new Point(40, 300);
            loigiai.Controls.Add(button3);
            button3.Click += Button3_Click;

            for (int i = 1; i <= 19; i++)
            {
                loigiai.Controls.Add(lg[i]);
            }
            loigiai.Size = new Size(800, 400);
            loigiai.ShowDialog();
        }
예제 #2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            this.AcceptButton = button4;
            LoiGiai loigiai = new LoiGiai();

            for (int i = 1; i < 20; i++)
            {
                lg[i].Font     = new Font("VNF-Comic Sans", 12);
                lg[i].AutoSize = true;
            }

            lg[1].Text     = "Đặt t =                               =>                                   = ";
            lg[1].Location = new Point(30, 40);

            pt[1].Image    = Properties.Resources.kchiafx;
            pt[1].Size     = new Size(118, 64);
            pt[1].Location = new Point(90, 20);

            pt[2].Image    = Properties.Resources.kchiafx2;
            pt[2].Size     = new Size(130, 64);
            pt[2].Location = new Point(235, 16);

            pt[3].Image    = Properties.Resources.ttru2k;
            pt[3].Size     = new Size(69, 27);
            pt[3].Location = new Point(380, 40);

            lg[2].Text = "=> (*)  <=>  " + soa;
            if (k != 0)
            {
                lg[2].Text = lg[2].Text + "(";
            }
            lg[2].Location = new Point(30, 85);

            pt[4].Image = Properties.Resources.tbinh;
            pt[4].Size  = new Size(27, 25);
            if (k != 0)
            {
                pt[4].Location = new Point(110 + (soa.Length + 1) * 7, 81);
            }
            else
            {
                pt[4].Location = new Point(110 + soa.Length * 7, 81);
            }
            pt[4].SizeMode = PictureBoxSizeMode.StretchImage;

            if (k != 0)
            {
                lg[3].Text = so2k + ")" + sob + soc + " = 0";
            }
            else
            {
                lg[3].Text = sob + soc;
            }
            lg[3].Location = new Point(pt[4].Location.X + 25, 85);

            lg[4].Text     = "<=>  " + soa;
            lg[4].Location = new Point(76, 115);

            pt[5].Image    = Properties.Resources.tbinh;
            pt[5].Size     = new Size(27, 25);
            pt[5].Location = new Point(110 + soa.Length * 7, 111);
            pt[5].SizeMode = PictureBoxSizeMode.StretchImage;

            lg[5].Text     = sob + soc_2k + " = 0  (1)";
            lg[5].Location = new Point(pt[5].Location.X + 25, 115);

            lg[6].Text     = "Giải (1) ta được";
            lg[6].Location = new Point(30, 145);

            if (d < 0)
            {
                lg[7].Text     = "(1) vô nghiệm";
                lg[7].Location = new Point(30, 175);
            }
            if (d == 0)
            {
                if (t1 > 0)
                {
                    if (Math.Round(t1, 3) != 1)
                    {
                        sot1 = "+ " + Math.Round(t1, 3) + "f(x) ";
                    }
                    else
                    {
                        sot1 = "+ f(x) ";
                    }
                }
                if (t1 < 0)
                {
                    if (Math.Round(t1, 3) != 1)
                    {
                        sot1 = "- " + Math.Round(-t1, 3) + "f(x) ";
                    }
                    else
                    {
                        sot1 = "- f(x) ";
                    }
                }

                lg[7].Text     = "t = " + Math.Round(t1, 3);
                lg[7].Location = new Point(40, 175);

                lg[8].Text     = "=>                               = " + Math.Round(t1, 3) + "  =>               " + sot1 + sok + " = 0";
                lg[8].Location = new Point(30, 215);

                pt[6].Image    = Properties.Resources.kchiafx;
                pt[6].Location = new Point(50, 205);
                pt[6].Size     = new Size(118, 64);

                pt[8].Image    = Properties.Resources.fxbinh;
                pt[8].Location = new Point((("=>                               = " + Math.Round(t1, 3) + "  =>               " + sot1 + sok + " = 0").Length - 16) * 8 + 10, 199);
                pt[8].Size     = new Size(47, 37);

                if (d1 < 0)
                {
                    lg[8].Text = lg[8].Text + " (vô nghiệm)";
                }
                if (d1 == 0)
                {
                    lg[8].Text = lg[8].Text + "=> f(x) = " + Math.Round(x1, 3);
                }
                if (d1 > 0)
                {
                    lg[8].Text = lg[8].Text + " => ";

                    pt[7].Image    = Properties.Resources.daungoac;
                    pt[7].Location = new Point(50 + lg[7].Text.Length * 5, 200);
                    pt[7].Size     = new Size(27, 58);

                    lg[9].Text     = "f(x) = " + Math.Round(x1, 3);
                    lg[9].Location = new Point(85 + lg[8].Text.Length * 5, 200);

                    lg[10].Text     = "f(x) = " + Math.Round(x2, 3);
                    lg[10].Location = new Point(85 + lg[8].Text.Length * 5, 230);
                }
            }

            if (d > 0)
            {
                if (t1 > 0)
                {
                    if (Math.Round(t1, 3) != 1)
                    {
                        sot1 = "- " + Math.Round(t1, 3) + "f(x) ";
                    }
                    else
                    {
                        sot1 = "- f(x) ";
                    }
                }
                if (t1 < 0)
                {
                    if (Math.Round(t1, 3) != -1)
                    {
                        sot1 = "+ " + Math.Round(-t1, 3) + "f(x) ";
                    }
                    else
                    {
                        sot1 = "+ f(x) ";
                    }
                }

                if (t2 > 0)
                {
                    if (Math.Round(t2, 3) != 1)
                    {
                        sot2 = "- " + Math.Round(t2, 3) + "f(x) ";
                    }
                    else
                    {
                        sot2 = "- f(x) ";
                    }
                }
                if (t2 < 0)
                {
                    if (Math.Round(t2, 3) != -1)
                    {
                        sot2 = "+ " + Math.Round(-t2, 3) + "f(x) ";
                    }
                    else
                    {
                        sot2 = "+ f(x) ";
                    }
                }

                //t1
                pt[6].Image    = Properties.Resources.daungoac;
                pt[6].Location = new Point(40, 175);
                pt[6].Size     = new Size(27, 58);

                lg[7].Text     = "t = " + Math.Round(t1, 3);
                lg[7].Location = new Point(70, 175);

                lg[8].Text     = "t = " + Math.Round(t2, 3);
                lg[8].Location = new Point(70, 205);

                lg[9].Text     = "Với " + lg[7].Text + " =>                               = " + Math.Round(t1, 3) + "  =>               " + sot1 + sok + " = 0";
                lg[9].Location = new Point(30, 255);

                pt[7].Image    = Properties.Resources.kchiafx;
                pt[7].Location = new Point(110 + (lg[7].Text.Length - 4) * 7, 235);
                pt[7].Size     = new Size(118, 64);

                pt[8].Image    = Properties.Resources.fxbinh;
                pt[8].Location = new Point((("Với " + lg[7].Text + " =>                               = " + Math.Round(t1, 3) + "  =>").Length - 16) * 8 + 10, 249);
                pt[8].Size     = new Size(47, 37);

                if (d1 < 0)
                {
                    lg[9].Text = lg[9].Text + " (vô nghiệm)";
                }
                if (d1 == 0)
                {
                    lg[9].Text = lg[9].Text + "=> f(x) = " + Math.Round(x1, 3);
                }
                if (d1 > 0)
                {
                    lg[9].Text = lg[9].Text + " => ";

                    pt[9].Image    = Properties.Resources.daungoac;
                    pt[9].Location = new Point(50 + lg[9].Text.Length * 5, 240);
                    pt[9].Size     = new Size(27, 58);

                    lg[10].Text     = "f(x) = " + Math.Round(x1, 3);
                    lg[10].Location = new Point(85 + lg[9].Text.Length * 5, 240);

                    lg[11].Text     = "f(x) = " + Math.Round(x2, 3);
                    lg[11].Location = new Point(85 + lg[9].Text.Length * 5, 270);
                }

                //t2
                lg[14].Text     = "Với " + lg[8].Text + " =>                               = " + Math.Round(t2, 3) + "  =>               " + sot2 + sok + " = 0";
                lg[14].Location = new Point(30, 320);

                pt[12].Image    = Properties.Resources.kchiafx;
                pt[12].Location = new Point(110 + (lg[8].Text.Length - 4) * 7, 300);
                pt[12].Size     = new Size(118, 64);

                pt[13].Image    = Properties.Resources.fxbinh;
                pt[13].Location = new Point((("Với " + lg[8].Text + " =>                               = " + Math.Round(t2, 3) + "  =>").Length - 16) * 8 + 10, 314);
                pt[13].Size     = new Size(47, 37);

                if (d2 < 0)
                {
                    lg[14].Text = lg[14].Text + " (vô nghiệm)";
                }
                if (d2 == 0)
                {
                    lg[14].Text = lg[14].Text + "=> f(x) = " + Math.Round(x3, 3);
                }
                if (d2 > 0)
                {
                    lg[14].Text = lg[14].Text + " => ";

                    pt[10].Image    = Properties.Resources.daungoac;
                    pt[10].Location = new Point(50 + lg[9].Text.Length * 5, 305);
                    pt[10].Size     = new Size(27, 58);

                    lg[15].Text     = "f(x) = " + Math.Round(x3, 3);
                    lg[15].Location = new Point(85 + lg[9].Text.Length * 5, 305);

                    lg[16].Text     = "f(x) = " + Math.Round(x4, 3);
                    lg[16].Location = new Point(85 + lg[9].Text.Length * 5, 335);
                }
            }

            lg[17].Text     = "Do f(x) = " + ham;
            lg[17].Location = new Point(30, 365);

            lg[18].Text     = kq[1];
            lg[18].Location = new Point(40, 395);

            lg[19].Text     = kq[2];
            lg[19].Location = new Point(40, 425);

            lg[20].Text     = kq[3];
            lg[20].Location = new Point(40, 455);

            lg[21].Text     = kq[4];
            lg[21].Location = new Point(40, 485);

            lg[22].Text     = kq[5];
            lg[22].Location = new Point(300, 395);

            lg[23].Text     = kq[6];
            lg[23].Location = new Point(300, 425);

            lg[24].Text     = kq[7];
            lg[24].Location = new Point(300, 455);

            lg[25].Text     = kq[8];
            lg[25].Location = new Point(300, 485);

            for (int i = 1; i < 20; i++)
            {
                loigiai.Controls.Add(pt[i]);
            }

            for (int i = 1; i < 30; i++)
            {
                loigiai.Controls.Add(lg[i]);
            }

            loigiai.Size = new Size(800, 600);
            loigiai.ShowDialog();
        }
예제 #3
0
        private void Button2_Click(object sender, EventArgs e)
        {
            this.AcceptButton = button4;

            Label[] lg      = new Label[20];
            LoiGiai loigiai = new LoiGiai();

            loigiai.AutoScroll = true;

            Label mau = new Label();

            mau.Font = new Font("VNF-Comic Sans", 12);

            for (int i = 1; i < 20; i++)
            {
                pt[i]      = new PictureBox();
                pt[i].Size = new Size(0, 0);
                loigiai.Controls.Add(pt[i]);
            }

            for (int i = 1; i < 20; i++)
            {
                lg[i]          = new Label();
                lg[i].Font     = mau.Font;
                lg[i].AutoSize = true;
                lg[i].Text     = "";
                lg[i].Size     = new Size(0, 0);
                loigiai.Controls.Add(lg[i]);
            }

            lg[1].Text     = "+) Xét cos(x) = 0 =>"; // sin(x)^1 = 1";
            lg[1].Location = new Point(20, 20);

            pt[1].Image    = Properties.Resources.sinb;
            pt[1].Size     = new Size(64, 30);
            pt[1].Location = new Point(15 + lg[1].Width, 17);

            lg[1].Text = lg[1].Text + "                 = 1";

            if (a == d)
            {
                lg[2].Text = "Do " + Math.Round(a, 4) + " = " + Math.Round(d, 4) + " => π/2 + kπ là nghiệm của phương trình";
                kt         = true;
            }
            else
            {
                lg[2].Text = "Do " + Math.Round(a, 4) + " ≠ " + Math.Round(d, 4) + " => π/2 + kπ không là nghiệm của phương trình";
            }
            lg[2].Location = new Point(30, 45);

            lg[3].Text     = "+) Xét cos(x) ≠ 0, chia cả 2 vế của (*) cho cos(x)^2, ta được: ";
            lg[3].Location = new Point(20, 70);

            if (a >= 0)
            {
                if (Math.Round(a, 3) != 1)
                {
                    soa = Math.Round(a, 3) + "";
                }
            }
            if (a < 0)
            {
                if (Math.Round(a, 3) != -1)
                {
                    soa = "- " + Math.Round(-a, 3);
                }
                else
                {
                    soa = "- ";
                }
            }
            if (b >= 0)
            {
                if (Math.Round(b, 3) != 1)
                {
                    sob = "+ " + Math.Round(b, 3);
                }
                else
                {
                    sob = "+ ";
                }
            }
            if (b < 0)
            {
                if (Math.Round(b, 3) != -1)
                {
                    sob = "- " + Math.Round(-b, 3);
                }
                else
                {
                    sob = "- ";
                }
            }
            if (c >= 0)
            {
                soc = "+ " + Math.Round(c, 3);
            }
            if (c < 0)
            {
                soc = "- " + Math.Round(-c, 3);
            }
            if (d >= 0)
            {
                if (Math.Round(d, 3) != 1)
                {
                    sod = "" + Math.Round(d, 3);
                }
            }
            if (d < 0)
            {
                if (Math.Round(d, 3) != -1)
                {
                    sod = "- " + Math.Round(-d, 3);
                }
                else
                {
                    sod = "- ";
                }
            }

            lg[4].Text     = soa;
            lg[4].Location = new Point(100, 120);

            pt[2].Image    = Properties.Resources.sinchiacos;
            pt[2].Size     = new Size(91, 65);
            pt[2].Location = new Point(95 + lg[4].Width, 100);

            lg[4].Text = lg[4].Text + "                     " + sob;

            pt[3].Image    = Properties.Resources.sincoschiacos;
            pt[3].Size     = new Size(110, 65);
            pt[3].Location = new Point(95 + lg[4].Width, 100);

            lg[4].Text = lg[4].Text + "                             " + soc;

            pt[4].Image    = Properties.Resources.coschiacos;
            pt[4].Size     = new Size(91, 68);
            pt[4].Location = new Point(95 + lg[4].Width, 100);

            lg[4].Text = lg[4].Text + "                        = " + sod;

            pt[5].Image    = Properties.Resources._1chiacos;
            pt[5].Size     = new Size(95, 68);
            pt[5].Location = new Point(95 + lg[4].Width, 100);

            if (a - d >= 0)
            {
                if (Math.Round(a - d, 3) != 1)
                {
                    soa = Math.Round(a - d, 3) + "";
                }
            }
            if (a - d < 0)
            {
                if (Math.Round(a - d, 3) != -1)
                {
                    soa = "- " + Math.Round(a - d, 3);
                }
                else
                {
                    soa = "- ";
                }
            }
            if (b >= 0)
            {
                if (Math.Round(b, 3) != 1)
                {
                    sob = "+ " + Math.Round(b, 3) + "tan(x) ";
                }
                else
                {
                    sob = "+ tan(x) ";
                }
            }
            if (b < 0)
            {
                if (Math.Round(b, 3) != -1)
                {
                    sob = "- " + Math.Round(-b, 3) + "tan(x) ";
                }
                else
                {
                    sob = "- tan(x) ";
                }
            }
            if (c >= 0)
            {
                soc = "+ " + Math.Round(c, 3);
            }
            if (c < 0)
            {
                soc = "- " + Math.Round(-c, 3);
            }

            lg[5].Text     = "<=>   " + soa;// + sob + soc + " = 0  (1)";
            lg[5].Location = new Point(65, 170);

            pt[6].Image    = Properties.Resources.tanb;
            pt[6].Size     = new Size(64, 30);
            pt[6].Location = new Point(60 + lg[5].Width, 166);

            lg[5].Text = lg[5].Text + "                  " + sob + soc + " = 0  (1)";

            lg[6].Text     = "Đặt t = tan(x), giải (1) ta được: ";
            lg[6].Location = new Point(30, 195);

            if (giai.d < 0)
            {
                lg[7].Text     = " (1) vô nghiệm";
                lg[7].Location = new Point(60, 220);
            }

            if (giai.d == 0)
            {
                lg[7].Text = "t = " + Math.Round(giai.x) + " => tan(x) = " + Math.Round(giai.x);
                if ((Math.Abs(giai.x - Math.PI / 2) <= 0.000000001))
                {
                    lg[7].Text = lg[7].Text + "  (loại)";
                }
                else
                {
                    lg[7].Text = lg[7].Text + " => " + ngh2;
                }
                lg[7].Location = new Point(60, 220);
            }

            if (giai.d > 0)
            {
                if (giai.kt == 1)
                {
                    lg[7].Location = new Point(60, 220);
                    lg[7].Text     = "(1) có vô số nghiệm";

                    lg[8].Location = new Point(60, 245);
                    lg[8].Text     = "(vì a,b,c = 0)";

                    lg[9].Location = new Point(60, 270);
                    lg[9].Text     = "=> (*) có vô số nghiệm x = arctan(t)  (t ≠ π/2 + kπ)";
                }
                else
                if (giai.kt == 2)
                {
                    lg[7].Location = new Point(60, 220);
                    lg[7].Text     = "(1) vô nghiệm";

                    lg[8].Location = new Point(60, 245);
                    lg[8].Text     = "(vì a,b = 0, c ≠ 0)";

                    lg[9].Location = new Point(60, 170);
                    lg[9].Text     = "=> (*) vô nghiệm";
                }
                else
                {
                    lg[7].Text = "t = " + Math.Round(giai.x1) + "=> tan(x) = " + Math.Round(giai.x1);
                    if ((Math.Abs(giai.x1 - Math.PI / 2) <= 0.000000001))
                    {
                        lg[7].Text = lg[7].Text + "  (loại)";
                    }
                    else
                    {
                        lg[7].Text = lg[7].Text + "=> " + ngh2;
                    }
                    lg[7].Location = new Point(60, 220);

                    lg[8].Text = "t = " + Math.Round(giai.x2) + "=> tan(x) = " + Math.Round(giai.x2);
                    if ((Math.Abs(giai.x2 - Math.PI / 2) <= 0.000000001))
                    {
                        lg[8].Text = lg[8].Text + "  (loại)";
                    }
                    else
                    {
                        lg[8].Text = lg[8].Text + "=> " + ngh3;
                    }
                    lg[8].Location = new Point(60, 245);
                }
            }

            if (ngh1 == "" && ngh2 == "" && ngh3 == "")
            {
                lg[9].Text     = "Vậy phương trình (*) vô nghiệm";
                lg[9].Location = new Point(30, 270);
            }
            else
            {
                lg[9].Text     = "Vậy phương trình (*) có nghiệm:";
                lg[9].Location = new Point(30, 270);
                int dong = 270;
                if (ngh1 != " ")
                {
                    dong            = dong + 25;
                    lg[10].Text     = ngh1;
                    lg[10].Location = new Point(60, dong);
                }

                if (ngh2 != " ")
                {
                    dong            = dong + 25;
                    lg[11].Text     = ngh2;
                    lg[11].Location = new Point(60, dong);
                }

                if (ngh3 != " ")
                {
                    dong            = dong + 25;
                    lg[12].Text     = ngh3;
                    lg[12].Location = new Point(60, dong);
                }
            }

            Button button3 = new Button();

            button3.Text     = "Hướng dẫn giải tổng quát";
            button3.Font     = button1.Font;
            button3.Size     = new Size(200, 40);
            button3.Location = new Point(40, 360);
            loigiai.Controls.Add(button3);
            button3.Click += Button3_Click;

            loigiai.Size     = new Size(650, 450);
            loigiai.AutoSize = true;

            loigiai.ShowDialog();
        }
예제 #4
0
        private void Button2_Click(object sender, EventArgs e)
        {
            this.AcceptButton = button4;

            Label[] lg      = new Label[20];
            LoiGiai loigiai = new LoiGiai();

            for (int i = 1; i < 20; i++)
            {
                pt[i]      = new PictureBox();
                pt[i].Size = new Size(0, 0);
                loigiai.Controls.Add(pt[i]);
            }

            for (int i = 1; i < 20; i++)
            {
                lg[i] = new Label();
            }
            for (int i = 1; i < 20; i++)
            {
                lg[i].Font     = new Font("VNF-Comic Sans", 12);
                lg[i].AutoSize = true;
                lg[i].Text     = "";
                lg[i].Size     = new Size(0, 0);
            }

            for (int i = 1; i < 20; i++)
            {
                loigiai.Controls.Add(lg[i]);
            }

            lg[1].Text     = "+) Xét cos(x) = 0 => ";
            lg[1].Location = new Point(20, 30);

            pt[1].Image    = Properties.Resources.sinb;
            pt[1].Size     = new Size(60, 31);
            pt[1].Location = new Point(15 + lg[1].Width, 25);

            lg[1].Text = lg[1].Text + "                = 1";

            if (a == 0)
            {
                lg[2].Text = "Do " + Math.Round(a, 4) + " = " + 0 + " => π/2 + kπ là nghiệm của phương trình";
                kt         = true;
            }
            else
            {
                lg[2].Text = "Do " + Math.Round(a, 4) + " ≠ " + 0 + " => π/2 + kπ không là nghiệm của phương trình";
            }
            lg[2].Location = new Point(30, 60);

            lg[3].Text     = "+) Xét cos(x) ≠ 0, chia cả 2 vế của (*) cho";
            lg[3].Location = new Point(30, 90);

            pt[2].Image    = Properties.Resources.cosmu3;
            pt[2].Size     = new Size(64, 30);
            pt[2].Location = new Point(lg[3].Width + 25, 88);

            lg[3].Text = lg[3].Text + "                , ta được:";

            lg[4].Text     = "(*)  <=>  " + soa;// + sob + soc + sod + " = 0";
            lg[4].Location = new Point(30, 120);

            pt[3].Image    = Properties.Resources.tanmu3;
            pt[3].Size     = new Size(64, 30);
            pt[3].Location = new Point(25 + lg[4].Width, 117);

            lg[4].Text = lg[4].Text + "                 " + sob;

            pt[4].Image    = Properties.Resources.tanx;
            pt[4].Size     = new Size(60, 30);
            pt[4].Location = new Point(25 + lg[4].Width, 122);

            lg[4].Text = lg[4].Text + "                " + soc + sod + " = 0";

            if (a + g >= 0)
            {
                if (Math.Round(a + g, 3) != 1)
                {
                    soa = Math.Round(a + g, 3) + "";
                }
            }
            if (a + g < 0)
            {
                if (Math.Round(a + g, 3) != -1)
                {
                    soa = "-" + Math.Round(-a - g, 3);
                }
            }
            if (b + f >= 0)
            {
                if (Math.Round(b + f, 3) != 1)
                {
                    sob = " + " + Math.Round(b + f, 3);
                }
                else
                {
                    sob = "+ ";
                }
            }
            if (b + f < 0)
            {
                if (Math.Round(b + f, 3) != -1)
                {
                    sob = "- " + Math.Round(-b - f, 3);
                }
                else
                {
                    sob = "- ";
                }
            }
            if (c + g > 0)
            {
                if (Math.Round(c + g, 3) != 1)
                {
                    soc = "+ " + Math.Round(c + g, 3) + "t ";
                }
            }
            if (c + g < 0)
            {
                if (Math.Round(c + g, 3) != -1)
                {
                    soc = "- " + Math.Round(-c - g, 3) + "t ";
                }
            }
            if (d + f > 0)
            {
                sod = "+ " + Math.Round(d + f, 3);
            }
            if (d + f < 0)
            {
                sod = "- " + Math.Round(-d - f, 3);
            }

            lg[5].Text     = "Đặt t = tan(x), ta được";
            lg[5].Location = new Point(30, 150);

            lg[6].Text     = "          " + soa;// + sob + soc + sod + " = 0   (1)";
            lg[6].Location = new Point(30, 180);

            pt[5].Image    = Properties.Resources.tmu3;
            pt[5].Size     = new Size(23, 23);
            pt[5].Location = new Point(25 + lg[6].Width, 178);

            lg[6].Text = lg[6].Text + "      " + sob;

            pt[6].Image    = Properties.Resources.tbinh;
            pt[6].Size     = new Size(23, 23);
            pt[6].Location = new Point(25 + lg[6].Width, 180);

            lg[6].Text = lg[6].Text + "      " + soc + sod + " = 0";

            lg[7].Text     = "Giải (1) ta được:";
            lg[7].Location = new Point(30, 210);

            int dong = 210;

            if (a == 0)
            {
                lg[8].Text     = "t = 0 => tan(x) = 0";
                lg[8].Location = new Point(30, dong + 30);
                dong           = dong + 30;
            }

            if (giai.conghiem1)
            {
                lg[9].Text     = "t = " + Math.Round(giai.x1, 3) + " => tan(x) = " + Math.Round(giai.x1, 3);
                lg[9].Location = new Point(30, dong + 30);
                dong           = dong + 30;
            }

            if (giai.conghiem2)
            {
                lg[10].Text     = "t = " + Math.Round(giai.x2, 3) + " => tan(x) = " + Math.Round(giai.x2, 3);
                lg[10].Location = new Point(30, dong + 30);
                dong            = dong + 30;
            }

            if (giai.conghiem3)
            {
                lg[11].Text     = "t = " + Math.Round(giai.x3, 3) + " => tan(x) = " + Math.Round(giai.x3, 3);
                lg[11].Location = new Point(30, dong + 30);
                dong            = dong + 30;
            }

            if (ngh1 == "" && ngh2 == "" && ngh3 == "" && ngh4 == "")
            {
                lg[12].Text     = "=> (*) vô nghiệm:";
                lg[12].Location = new Point(20, dong + 30);
            }
            else
            {
                lg[12].Text     = "=> (*) có nghiệm:";
                lg[12].Location = new Point(20, dong + 30);
                dong            = dong + 30;

                if (ngh1 != "")
                {
                    lg[13].Text     = ngh1;
                    lg[13].Location = new Point(30, dong + 30);
                    dong            = dong + 30;
                }

                if (ngh2 != "")
                {
                    lg[14].Text     = ngh2;
                    lg[14].Location = new Point(30, dong + 30);
                    dong            = dong + 30;
                }

                if (ngh3 != "")
                {
                    lg[15].Text     = ngh3;
                    lg[15].Location = new Point(30, dong + 30);
                    dong            = dong + 30;
                }

                if (ngh4 != "")
                {
                    lg[16].Text     = ngh4;
                    lg[16].Location = new Point(30, dong + 30);
                    dong            = dong + 30;
                }
            }

            Button button3 = new Button();

            button3.Text     = "Hướng dẫn giải tổng quát";
            button3.Font     = button1.Font;
            button3.Size     = new Size(200, 40);
            button3.Location = new Point(40, 480);
            loigiai.Controls.Add(button3);
            button3.Click += Button3_Click;

            for (int i = 1; i < 20; i++)
            {
                loigiai.Controls.Add(lg[i]);
            }
            loigiai.AutoSize = true;
            loigiai.Size     = new Size(550, 620);
            loigiai.Controls.Add(button3);
            loigiai.ShowDialog();
        }
예제 #5
0
        private void Button2_Click(object sender, EventArgs e)
        {
            this.AcceptButton = button4;

            LoiGiai loigiai = new LoiGiai();

            PictureBox ptb1 = new PictureBox();

            loigiai.Controls.Add(ptb1);

            PictureBox pt = new PictureBox();

            loigiai.Controls.Add(pt);

            Label mau = new Label();

            mau.Font = new Font("VNF-Comic Sans", 12);
            for (int i = 1; i < 20; i++)
            {
                lg[i]          = new Label();
                lg[i].Font     = mau.Font;
                lg[i].AutoSize = true;
                lg[i].Text     = "";
                loigiai.Controls.Add(lg[i]);
            }

            if (radioButton1.Checked == true)
            {
                lg[1].Text = "Đặt t = sin(x) + cos(x)  => sin(x)cos(x) =";
            }
            else
            {
                lg[1].Text = "Đặt t = cos(x) - sin(x)  => sin(x)cos(x) =";
            }
            lg[1].Location = new Point(30, 40);

            if (radioButton1.Checked == true)
            {
                ptb1.BackgroundImage = Properties.Resources.t_1chia2;
            }
            else
            {
                ptb1.BackgroundImage = Properties.Resources._1_tchia2;
            }
            ptb1.Location = new Point();
            ptb1.Size     = new Size(71, 68);
            ptb1.Location = new Point(325, 20);

            lg[2].Text     = "(|t| <= sqrt(2)), ta được:";
            lg[2].Location = new Point(400, 40);

            if (b >= 0)
            {
                if (Math.Round(b, 3) != 1)
                {
                    soa = Math.Round(b, 3) + "";
                }
            }
            if (b < 0)
            {
                if (Math.Round(b, 3) != -1)
                {
                    soa = "-" + Math.Round(-b, 3);
                }
                else
                {
                    soa = "- ";
                }
            }
            if (a > 0)
            {
                if (Math.Round(a, 3) != 1)
                {
                    sob1 = "+ " + 2 * Math.Round(a, 3) + "t ";
                    sob2 = "- " + 2 * Math.Round(a, 3) + "t ";
                }
                else
                {
                    sob1 = "+ t ";
                    sob2 = "- t ";
                }
            }
            if (a < 0)
            {
                if (Math.Round(b, 3) != -1)
                {
                    sob1 = "- " + 2 * Math.Round(-a, 3) + "t ";
                    sob2 = "+ " + 2 * Math.Round(-a, 3) + "t ";
                }
                else
                {
                    sob1 = "- t ";
                    sob2 = "+ t ";
                }
            }
            if (b + 2 * c > 0)
            {
                soc = "= " + Math.Round(b + 2 * c, 3);
            }
            if (b + 2 * c < 0)
            {
                soc = "= -" + Math.Round(-(b + 2 * c), 3);
            }

            lg[3].Text = soa;

            pt.Image    = Properties.Resources.tbinh;
            pt.Size     = new Size(23, 23);
            pt.Location = new Point(95 + lg[3].Width, 80);

            if (radioButton1.Checked)
            {
                lg[3].Text = lg[3].Text + "       " + sob1 + soc;
            }
            else
            {
                lg[3].Text = lg[3].Text + "       " + sob2 + soc;
            }
            lg[3].Location = new Point(100, 80);

            lg[4].Text     = "Giải (1) ta được:";
            lg[4].Location = new Point(40, 105);

            if (giai.d < 0)
            {
                lg[5].Text = "(1) vô nghiệm";
            }
            if (giai.d == 0)
            {
                lg[5].Text = "t = " + Math.Round(x, 4);
                if (Math.Abs(x) > Math.Sqrt(2))
                {
                    lg[5].Text = lg[5].Text + "  => loại";
                }
            }
            if (giai.d > 0)
            {
                lg[5].Text = "t = " + Math.Round(x1, 4);
                if (Math.Abs(x1) > Math.Sqrt(2))
                {
                    lg[5].Text = lg[5].Text + "  => loại";
                }
                lg[6].Text = "t = " + Math.Round(x2, 4);
                if (Math.Abs(x2) > Math.Sqrt(2))
                {
                    lg[6].Text = lg[6].Text + "  => loại";
                }
            }

            lg[5].Location = new Point(60, 130);
            lg[6].Location = new Point(60, 155);

            if (giai.d < 0)
            {
                lg[7].Text = "Vậy phương trình vô nghiệm";
            }
            else
            {
                lg[7].Text  = "Vậy phương trình có nghiệm:";
                lg[8].Text  = kq[1];
                lg[9].Text  = kq[2];
                lg[10].Text = kq[3];
                lg[11].Text = kq[4];

                lg[7].Location  = new Point(40, 180);
                lg[8].Location  = new Point(60, 205);
                lg[9].Location  = new Point(60, 230);
                lg[10].Location = new Point(60, 255);
                lg[11].Location = new Point(60, 280);
            }

            Button button3 = new Button();

            button3.Text     = "Hướng dẫn giải tổng quát";
            button3.Font     = button1.Font;
            button3.Size     = new Size(200, 40);
            button3.Location = new Point(40, 320);
            loigiai.Controls.Add(button3);
            button3.Click += Button3_Click;

            loigiai.Size = new Size(800, 450);
            loigiai.ShowDialog();
        }
예제 #6
0
        private void Button2_Click(object sender, EventArgs e)
        {
            this.AcceptButton = button4;
            LoiGiai loigiai = new LoiGiai();

            for (int i = 1; i < 30; i++)
            {
                lg[i]          = new Label();
                lg[i].Font     = new Font("VNF-Comic Sans", 12);
                lg[i].AutoSize = true;
                lg[i].Size     = new Size(0, 0);

                pt[i]      = new PictureBox();
                pt[i].Size = new Size(0, 0);
            }

            for (int i = 1; i < 30; i++)
            {
                loigiai.Controls.Add(pt[i]);
            }
            for (int i = 1; i < 30; i++)
            {
                loigiai.Controls.Add(lg[i]);
            }

            lg[1].Text     = "Đặt t = " + som + "tan(x)  " + sonc + "cot(x) ";
            lg[1].Location = new Point(30, 30);

            lg[2].Text     = "=> " + somb;
            lg[2].Location = new Point(30, 60);

            pt[1].Image    = Properties.Resources.tanx;
            pt[1].Location = new Point(25 + lg[2].Width, 62);
            pt[1].Size     = new Size(63, 24);

            lg[2].Text = lg[2].Text + "                  " + sonb;

            pt[2].Image    = Properties.Resources.cotx;
            pt[2].Location = new Point(25 + lg[2].Width, 62);
            pt[2].Size     = new Size(63, 24);

            lg[2].Text = lg[2].Text + "                   = ";

            pt[3].Image    = Properties.Resources.tbinh;
            pt[3].Location = new Point(lg[2].Width + 25, 54);
            pt[3].Size     = new Size(27, 25);
            pt[3].SizeMode = PictureBoxSizeMode.StretchImage;

            lg[2].Text = lg[2].Text + "         " + somn;

            lg[3].Text     = "=> (*)  <=>  " + soa + "(";
            lg[3].Location = new Point(30, 90);

            pt[4].Image    = Properties.Resources.tbinh;
            pt[4].Location = new Point(lg[3].Width + 25, 84);
            pt[4].Size     = new Size(27, 25);

            lg[3].Text = lg[3].Text + "       " + somn + ") " + sob + soc + " = 0";

            lg[4].Text     = "<=>  " + soa;
            lg[4].Location = new Point(75, 120);

            pt[5].Image    = Properties.Resources.tbinh;
            pt[5].Size     = new Size(27, 25);
            pt[5].Location = new Point(lg[4].Width + 70, 114);

            lg[4].Text += "       " + sob + socamn + " = 0";

            if (d < 0)
            {
                lg[4].Text = lg[4].Text + "   (vô nghiệm)";
            }
            if (d == 0)
            {
                lg[5].Text     = "<=>  t = " + Math.Round(t1, 3);
                lg[5].Location = new Point(75, 150);

                lg[6].Text     = " => " + som + "tan(x)  " + sonc + "cot(x) = " + Math.Round(t1, 3);
                lg[6].Location = new Point(75, 180);

                lg[7].Text     = "<=>  " + som;
                lg[7].Location = new Point(75, 210);

                pt[6].Image    = Properties.Resources.tanx;
                pt[6].Size     = new Size(63, 24);
                pt[6].Location = new Point(lg[7].Width + 25, 212);

                lg[7].Text += "                 " + sot1 + son;
            }
            if (d > 0)
            {
                lg[5].Text     = "<=>";
                lg[5].Location = new Point(75, 165);

                pt[6].Image    = Properties.Resources.daungoac;
                pt[6].Size     = new Size(27, 58);
                pt[6].Location = new Point(100, 150);

                lg[6].Text     = "t = " + Math.Round(t1, 3);
                lg[6].Location = new Point(130, 150);

                lg[7].Text     = "t = " + Math.Round(t2, 3);
                lg[7].Location = new Point(130, 180);

                //t1
                lg[8].Text = "Với t = " + Math.Round(t1, 3) + " => " + som + "tan(x) " + son + "cot(x) = " + Math.Round(t1, 3) + " => " + som;
                if (d1 <= 0)
                {
                    lg[8].Location = new Point(30, 210);
                }
                else
                {
                    lg[8].Location = new Point(30, 225);
                }

                pt[7].Image = Properties.Resources.tanx;
                pt[7].Size  = new Size(63, 24);
                if (d1 <= 0)
                {
                    pt[7].Location = new Point(lg[8].Size.Width + 25, 212);
                }
                else
                {
                    pt[7].Location = new Point(lg[8].Size.Width + 25, 227);
                }

                lg[8].Text = lg[8].Text + "                 " + sot1 + son + " = 0";

                if (d1 < 0)
                {
                    lg[8].Text = lg[8].Text + "  (vô nghiệm)";
                }
                if (d1 == 0)
                {
                    lg[8].Text = lg[8].Text + " => tan(x) = " + Math.Round(x1, 3);
                }
                if (d1 > 0)
                {
                    lg[8].Text = lg[8].Text + " => ";

                    pt[8].Image    = Properties.Resources.daungoac;
                    pt[8].Size     = new Size(27, 58);
                    pt[8].Location = new Point(lg[8].Width + 30, 210);

                    lg[9].Text     = "tan(x) = " + Math.Round(x1, 3);
                    lg[9].Location = new Point(lg[8].Width + 60, 210);

                    lg[10].Text     = "tan(x) = " + Math.Round(x2, 3);
                    lg[10].Location = new Point(lg[8].Width + 60, 240);
                }

                //t2
                lg[11].Text = "Với t = " + Math.Round(t2, 3) + " => " + som + "tan(x) " + son + "cot(x) = " + Math.Round(t2, 3) + " => " + som;
                if (d2 <= 0)
                {
                    lg[11].Location = new Point(30, 270);
                }
                else
                {
                    lg[11].Location = new Point(30, 285);
                }

                pt[9].Image = Properties.Resources.tanx;
                pt[9].Size  = new Size(63, 24);
                if (d2 <= 0)
                {
                    pt[9].Location = new Point(lg[11].Width + 25, 272);
                }
                else
                {
                    pt[9].Location = new Point(lg[11].Width + 25, 287);
                }

                lg[11].Text += "                 " + sot2 + son + " = 0";

                if (d2 < 0)
                {
                    lg[11].Text += " (vô nghiệm)";
                }
                if (d2 == 0)
                {
                    lg[11].Text += " => tan(x) = " + Math.Round(x3, 3);
                }
                if (d2 > 0)
                {
                    lg[11].Text += " => ";

                    pt[10].Image    = Properties.Resources.daungoac;
                    pt[10].Size     = new Size(27, 58);
                    pt[10].Location = new Point(lg[11].Width + 30, 270);

                    lg[12].Text     = "tan(x) = " + Math.Round(x3, 3);
                    lg[12].Location = new Point(lg[11].Width + 60, 270);

                    lg[13].Text     = "tan(x) = " + Math.Round(x4, 3);
                    lg[13].Location = new Point(lg[11].Width + 60, 300);
                }
            }

            lg[14].Text     = "Phương trình có nghiệm: ";
            lg[14].Location = new Point(30, 330);

            lg[15].Text     = kq[1];
            lg[15].Location = new Point(40, 360);

            lg[16].Text     = kq[2];
            lg[16].Location = new Point(40, 390);

            lg[17].Text     = kq[3];
            lg[17].Location = new Point(40, 420);

            lg[18].Text     = kq[4];
            lg[18].Location = new Point(40, 450);

            Button button3 = new Button();

            button3.Text     = "Hướng dẫn giải tổng quát";
            button3.Font     = button1.Font;
            button3.Size     = new Size(200, 40);
            button3.Location = new Point(40, 480);
            loigiai.Controls.Add(button3);
            button3.Click += Button3_Click;

            loigiai.Size = new Size(800, 600);
            loigiai.ShowDialog();
        }