Advertisement
X_Future

Untitled

May 13th, 2024
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 47.02 KB | None | 0 0
  1. #pragma once
  2. #include <math.h>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <sstream>
  6. namespace CALCLAB2 {
  7.  
  8.     using namespace System;
  9.     using namespace System::ComponentModel;
  10.     using namespace System::Collections;
  11.     using namespace System::Windows::Forms;
  12.     using namespace System::Data;
  13.     using namespace System::Drawing;
  14.  
  15.     /// <summary>
  16.     /// Сводка для EqForm
  17.     /// </summary>
  18.     public ref class EqForm : public System::Windows::Forms::Form
  19.     {
  20.     public:
  21.         EqForm(void)
  22.         {
  23.             InitializeComponent();
  24.             //
  25.             //TODO: добавьте код конструктора
  26.             //
  27.         }
  28.  
  29.     protected:
  30.         /// <summary>
  31.         /// Освободить все используемые ресурсы.
  32.         /// </summary>
  33.         ~EqForm()
  34.         {
  35.             if (components)
  36.             {
  37.                 delete components;
  38.             }
  39.         }
  40.     private: System::Windows::Forms::RadioButton^ eqrb1;
  41.     private: System::Windows::Forms::RadioButton^ eqrb2;
  42.     private: System::Windows::Forms::RadioButton^ eqrb3;
  43.     private: System::Windows::Forms::RadioButton^ eqrb4;
  44.     protected:
  45.  
  46.     protected:
  47.  
  48.  
  49.  
  50.     private: System::Windows::Forms::GroupBox^ groupBox1;
  51.     private: System::Windows::Forms::GroupBox^ groupBox2;
  52.     private: System::Windows::Forms::TextBox^ BXtxt;
  53.  
  54.     private: System::Windows::Forms::TextBox^ X0txt;
  55.  
  56.     private: System::Windows::Forms::TextBox^ AXtxt;
  57.  
  58.     private: System::Windows::Forms::Label^ label1;
  59.     private: System::Windows::Forms::TextBox^ BYtxt;
  60.  
  61.     private: System::Windows::Forms::TextBox^ Y0txt;
  62.     private: System::Windows::Forms::TextBox^ AYtxt;
  63.  
  64.  
  65.     private: System::Windows::Forms::Label^ label7;
  66.     private: System::Windows::Forms::TextBox^ EPStext;
  67.  
  68.     private: System::Windows::Forms::Label^ label6;
  69.     private: System::Windows::Forms::Label^ label5;
  70.     private: System::Windows::Forms::Label^ label3;
  71.     private: System::Windows::Forms::Label^ label4;
  72.     private: System::Windows::Forms::Label^ label2;
  73.     private: System::Windows::Forms::Label^ label8;
  74.     private: System::Windows::Forms::Label^ label10;
  75.     private: System::Windows::Forms::Label^ label11;
  76.     private: System::Windows::Forms::Label^ label9;
  77.     private: System::Windows::Forms::PictureBox^ pictureBox1;
  78.     private: System::Windows::Forms::GroupBox^ groupBox3;
  79.     private: System::Windows::Forms::Button^ button1;
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.     private: System::Windows::Forms::DataGridView^ table;
  93.     private: System::Windows::Forms::Label^ label17;
  94.     private: System::Windows::Forms::ComboBox^ method;
  95.     private: System::Windows::Forms::TextBox^ textBox3;
  96.     private: System::Windows::Forms::RadioButton^ eqrb5;
  97.     private: System::Windows::Forms::PictureBox^ pictureBox5;
  98.     private: System::Windows::Forms::PictureBox^ pictureBox4;
  99.     private: System::Windows::Forms::PictureBox^ pictureBox3;
  100.     private: System::Windows::Forms::PictureBox^ pictureBox2;
  101.     private: System::Windows::Forms::PictureBox^ pictureBox6;
  102.  
  103.  
  104.  
  105.     private:
  106.         /// <summary>
  107.         /// Обязательная переменная конструктора.
  108.         /// </summary>
  109.         System::ComponentModel::Container ^components;
  110.  
  111. #pragma region Windows Form Designer generated code
  112.         /// <summary>
  113.         /// Требуемый метод для поддержки конструктора — не изменяйте
  114.         /// содержимое этого метода с помощью редактора кода.
  115.         /// </summary>
  116.         void InitializeComponent(void)
  117.         {
  118.             System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(EqForm::typeid));
  119.             this->eqrb1 = (gcnew System::Windows::Forms::RadioButton());
  120.             this->eqrb2 = (gcnew System::Windows::Forms::RadioButton());
  121.             this->eqrb3 = (gcnew System::Windows::Forms::RadioButton());
  122.             this->eqrb4 = (gcnew System::Windows::Forms::RadioButton());
  123.             this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
  124.             this->eqrb5 = (gcnew System::Windows::Forms::RadioButton());
  125.             this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
  126.             this->label17 = (gcnew System::Windows::Forms::Label());
  127.             this->method = (gcnew System::Windows::Forms::ComboBox());
  128.             this->button1 = (gcnew System::Windows::Forms::Button());
  129.             this->label10 = (gcnew System::Windows::Forms::Label());
  130.             this->label11 = (gcnew System::Windows::Forms::Label());
  131.             this->label9 = (gcnew System::Windows::Forms::Label());
  132.             this->label8 = (gcnew System::Windows::Forms::Label());
  133.             this->label7 = (gcnew System::Windows::Forms::Label());
  134.             this->EPStext = (gcnew System::Windows::Forms::TextBox());
  135.             this->label6 = (gcnew System::Windows::Forms::Label());
  136.             this->label5 = (gcnew System::Windows::Forms::Label());
  137.             this->label3 = (gcnew System::Windows::Forms::Label());
  138.             this->label4 = (gcnew System::Windows::Forms::Label());
  139.             this->label2 = (gcnew System::Windows::Forms::Label());
  140.             this->label1 = (gcnew System::Windows::Forms::Label());
  141.             this->BYtxt = (gcnew System::Windows::Forms::TextBox());
  142.             this->Y0txt = (gcnew System::Windows::Forms::TextBox());
  143.             this->AYtxt = (gcnew System::Windows::Forms::TextBox());
  144.             this->BXtxt = (gcnew System::Windows::Forms::TextBox());
  145.             this->X0txt = (gcnew System::Windows::Forms::TextBox());
  146.             this->AXtxt = (gcnew System::Windows::Forms::TextBox());
  147.             this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
  148.             this->groupBox3 = (gcnew System::Windows::Forms::GroupBox());
  149.             this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  150.             this->table = (gcnew System::Windows::Forms::DataGridView());
  151.             this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());
  152.             this->pictureBox3 = (gcnew System::Windows::Forms::PictureBox());
  153.             this->pictureBox4 = (gcnew System::Windows::Forms::PictureBox());
  154.             this->pictureBox5 = (gcnew System::Windows::Forms::PictureBox());
  155.             this->pictureBox6 = (gcnew System::Windows::Forms::PictureBox());
  156.             this->groupBox1->SuspendLayout();
  157.             this->groupBox2->SuspendLayout();
  158.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
  159.             this->groupBox3->SuspendLayout();
  160.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->table))->BeginInit();
  161.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox2))->BeginInit();
  162.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox3))->BeginInit();
  163.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox4))->BeginInit();
  164.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox5))->BeginInit();
  165.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox6))->BeginInit();
  166.             this->SuspendLayout();
  167.             //
  168.             // eqrb1
  169.             //
  170.             this->eqrb1->AutoSize = true;
  171.             this->eqrb1->Location = System::Drawing::Point(6, 30);
  172.             this->eqrb1->Name = L"eqrb1";
  173.             this->eqrb1->Size = System::Drawing::Size(126, 26);
  174.             this->eqrb1->TabIndex = 0;
  175.             this->eqrb1->TabStop = true;
  176.             this->eqrb1->Text = L"Equation 1";
  177.             this->eqrb1->UseVisualStyleBackColor = true;
  178.             this->eqrb1->CheckedChanged += gcnew System::EventHandler(this, &EqForm::eqrb1_CheckedChanged);
  179.             //
  180.             // eqrb2
  181.             //
  182.             this->eqrb2->AutoSize = true;
  183.             this->eqrb2->Location = System::Drawing::Point(6, 62);
  184.             this->eqrb2->Name = L"eqrb2";
  185.             this->eqrb2->Size = System::Drawing::Size(126, 26);
  186.             this->eqrb2->TabIndex = 1;
  187.             this->eqrb2->TabStop = true;
  188.             this->eqrb2->Text = L"Equation 2";
  189.             this->eqrb2->UseVisualStyleBackColor = true;
  190.             this->eqrb2->CheckedChanged += gcnew System::EventHandler(this, &EqForm::eqrb2_CheckedChanged);
  191.             //
  192.             // eqrb3
  193.             //
  194.             this->eqrb3->AutoSize = true;
  195.             this->eqrb3->Location = System::Drawing::Point(6, 94);
  196.             this->eqrb3->Name = L"eqrb3";
  197.             this->eqrb3->Size = System::Drawing::Size(126, 26);
  198.             this->eqrb3->TabIndex = 2;
  199.             this->eqrb3->TabStop = true;
  200.             this->eqrb3->Text = L"Equation 3";
  201.             this->eqrb3->UseVisualStyleBackColor = true;
  202.             this->eqrb3->CheckedChanged += gcnew System::EventHandler(this, &EqForm::eqrb3_CheckedChanged);
  203.             //
  204.             // eqrb4
  205.             //
  206.             this->eqrb4->AutoSize = true;
  207.             this->eqrb4->Location = System::Drawing::Point(441, 30);
  208.             this->eqrb4->Name = L"eqrb4";
  209.             this->eqrb4->Size = System::Drawing::Size(126, 26);
  210.             this->eqrb4->TabIndex = 3;
  211.             this->eqrb4->TabStop = true;
  212.             this->eqrb4->Text = L"Equation 4";
  213.             this->eqrb4->UseVisualStyleBackColor = true;
  214.             this->eqrb4->CheckedChanged += gcnew System::EventHandler(this, &EqForm::eqrb4_CheckedChanged);
  215.             //
  216.             // groupBox1
  217.             //
  218.             this->groupBox1->Controls->Add(this->pictureBox6);
  219.             this->groupBox1->Controls->Add(this->pictureBox5);
  220.             this->groupBox1->Controls->Add(this->pictureBox4);
  221.             this->groupBox1->Controls->Add(this->pictureBox3);
  222.             this->groupBox1->Controls->Add(this->pictureBox2);
  223.             this->groupBox1->Controls->Add(this->eqrb5);
  224.             this->groupBox1->Controls->Add(this->eqrb4);
  225.             this->groupBox1->Controls->Add(this->eqrb3);
  226.             this->groupBox1->Controls->Add(this->eqrb2);
  227.             this->groupBox1->Controls->Add(this->eqrb1);
  228.             this->groupBox1->Font = (gcnew System::Drawing::Font(L"Century Gothic", 14.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
  229.                 static_cast<System::Byte>(0)));
  230.             this->groupBox1->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
  231.                 static_cast<System::Int32>(static_cast<System::Byte>(255)));
  232.             this->groupBox1->Location = System::Drawing::Point(12, 12);
  233.             this->groupBox1->Name = L"groupBox1";
  234.             this->groupBox1->Size = System::Drawing::Size(856, 131);
  235.             this->groupBox1->TabIndex = 4;
  236.             this->groupBox1->TabStop = false;
  237.             this->groupBox1->Text = L"Choose one BUDDY";
  238.             //
  239.             // eqrb5
  240.             //
  241.             this->eqrb5->AutoSize = true;
  242.             this->eqrb5->Location = System::Drawing::Point(441, 83);
  243.             this->eqrb5->Name = L"eqrb5";
  244.             this->eqrb5->Size = System::Drawing::Size(126, 26);
  245.             this->eqrb5->TabIndex = 4;
  246.             this->eqrb5->TabStop = true;
  247.             this->eqrb5->Text = L"Equation 5";
  248.             this->eqrb5->UseVisualStyleBackColor = true;
  249.             this->eqrb5->CheckedChanged += gcnew System::EventHandler(this, &EqForm::eqrb5_CheckedChanged);
  250.             //
  251.             // groupBox2
  252.             //
  253.             this->groupBox2->Controls->Add(this->label17);
  254.             this->groupBox2->Controls->Add(this->method);
  255.             this->groupBox2->Controls->Add(this->button1);
  256.             this->groupBox2->Controls->Add(this->label10);
  257.             this->groupBox2->Controls->Add(this->label11);
  258.             this->groupBox2->Controls->Add(this->label9);
  259.             this->groupBox2->Controls->Add(this->label8);
  260.             this->groupBox2->Controls->Add(this->label7);
  261.             this->groupBox2->Controls->Add(this->EPStext);
  262.             this->groupBox2->Controls->Add(this->label6);
  263.             this->groupBox2->Controls->Add(this->label5);
  264.             this->groupBox2->Controls->Add(this->label3);
  265.             this->groupBox2->Controls->Add(this->label4);
  266.             this->groupBox2->Controls->Add(this->label2);
  267.             this->groupBox2->Controls->Add(this->label1);
  268.             this->groupBox2->Controls->Add(this->BYtxt);
  269.             this->groupBox2->Controls->Add(this->Y0txt);
  270.             this->groupBox2->Controls->Add(this->AYtxt);
  271.             this->groupBox2->Controls->Add(this->BXtxt);
  272.             this->groupBox2->Controls->Add(this->X0txt);
  273.             this->groupBox2->Controls->Add(this->AXtxt);
  274.             this->groupBox2->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  275.                 static_cast<System::Byte>(204)));
  276.             this->groupBox2->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
  277.                 static_cast<System::Int32>(static_cast<System::Byte>(255)));
  278.             this->groupBox2->Location = System::Drawing::Point(12, 149);
  279.             this->groupBox2->Name = L"groupBox2";
  280.             this->groupBox2->Size = System::Drawing::Size(326, 444);
  281.             this->groupBox2->TabIndex = 5;
  282.             this->groupBox2->TabStop = false;
  283.             this->groupBox2->Text = L"Input VALUES";
  284.             this->groupBox2->Enter += gcnew System::EventHandler(this, &EqForm::groupBox2_Enter);
  285.             //
  286.             // label17
  287.             //
  288.             this->label17->AutoSize = true;
  289.             this->label17->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  290.                 static_cast<System::Byte>(0)));
  291.             this->label17->Location = System::Drawing::Point(11, 29);
  292.             this->label17->Name = L"label17";
  293.             this->label17->Size = System::Drawing::Size(235, 33);
  294.             this->label17->TabIndex = 29;
  295.             this->label17->Text = L"Solving METHOD:";
  296.             this->label17->Click += gcnew System::EventHandler(this, &EqForm::label17_Click);
  297.             //
  298.             // method
  299.             //
  300.             this->method->FormattingEnabled = true;
  301.             this->method->Items->AddRange(gcnew cli::array< System::Object^  >(4) {
  302.                 L"Slicing (1 variable)", L"Split in half (1 variable)",
  303.                     L"Simple iteration (1 variable)", L"Newthon\'s (2 variables)"
  304.             });
  305.             this->method->Location = System::Drawing::Point(6, 64);
  306.             this->method->Name = L"method";
  307.             this->method->Size = System::Drawing::Size(312, 27);
  308.             this->method->TabIndex = 19;
  309.             this->method->SelectedIndexChanged += gcnew System::EventHandler(this, &EqForm::comboBox1_SelectedIndexChanged);
  310.             //
  311.             // button1
  312.             //
  313.             this->button1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"button1.BackgroundImage")));
  314.             this->button1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
  315.             this->button1->Font = (gcnew System::Drawing::Font(L"Papyrus", 21.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  316.                 static_cast<System::Byte>(0)));
  317.             this->button1->Location = System::Drawing::Point(6, 341);
  318.             this->button1->Name = L"button1";
  319.             this->button1->Size = System::Drawing::Size(314, 97);
  320.             this->button1->TabIndex = 18;
  321.             this->button1->Text = L"GO!!!!!!!";
  322.             this->button1->UseVisualStyleBackColor = true;
  323.             this->button1->Click += gcnew System::EventHandler(this, &EqForm::button1_Click);
  324.             //
  325.             // label10
  326.             //
  327.             this->label10->AutoSize = true;
  328.             this->label10->Location = System::Drawing::Point(202, 242);
  329.             this->label10->Name = L"label10";
  330.             this->label10->Size = System::Drawing::Size(31, 19);
  331.             this->label10->TabIndex = 17;
  332.             this->label10->Text = L"<=";
  333.             //
  334.             // label11
  335.             //
  336.             this->label11->AutoSize = true;
  337.             this->label11->Location = System::Drawing::Point(94, 242);
  338.             this->label11->Name = L"label11";
  339.             this->label11->Size = System::Drawing::Size(31, 19);
  340.             this->label11->TabIndex = 16;
  341.             this->label11->Text = L"<=";
  342.             //
  343.             // label9
  344.             //
  345.             this->label9->AutoSize = true;
  346.             this->label9->Location = System::Drawing::Point(202, 164);
  347.             this->label9->Name = L"label9";
  348.             this->label9->Size = System::Drawing::Size(31, 19);
  349.             this->label9->TabIndex = 15;
  350.             this->label9->Text = L"<=";
  351.             //
  352.             // label8
  353.             //
  354.             this->label8->AutoSize = true;
  355.             this->label8->Location = System::Drawing::Point(94, 164);
  356.             this->label8->Name = L"label8";
  357.             this->label8->Size = System::Drawing::Size(31, 19);
  358.             this->label8->TabIndex = 14;
  359.             this->label8->Text = L"<=";
  360.             this->label8->Click += gcnew System::EventHandler(this, &EqForm::label8_Click);
  361.             //
  362.             // label7
  363.             //
  364.             this->label7->AutoSize = true;
  365.             this->label7->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  366.                 static_cast<System::Byte>(0)));
  367.             this->label7->Location = System::Drawing::Point(6, 291);
  368.             this->label7->Name = L"label7";
  369.             this->label7->Size = System::Drawing::Size(101, 33);
  370.             this->label7->TabIndex = 13;
  371.             this->label7->Text = L"Epsilon:";
  372.             this->label7->Click += gcnew System::EventHandler(this, &EqForm::label7_Click);
  373.             //
  374.             // EPStext
  375.             //
  376.             this->EPStext->BackColor = System::Drawing::SystemColors::InfoText;
  377.             this->EPStext->ForeColor = System::Drawing::SystemColors::ButtonFace;
  378.             this->EPStext->Location = System::Drawing::Point(112, 295);
  379.             this->EPStext->Name = L"EPStext";
  380.             this->EPStext->Size = System::Drawing::Size(100, 26);
  381.             this->EPStext->TabIndex = 12;
  382.             this->EPStext->TextChanged += gcnew System::EventHandler(this, &EqForm::textBox7_TextChanged);
  383.             //
  384.             // label6
  385.             //
  386.             this->label6->AutoSize = true;
  387.             this->label6->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  388.                 static_cast<System::Byte>(0)));
  389.             this->label6->Location = System::Drawing::Point(146, 235);
  390.             this->label6->Name = L"label6";
  391.             this->label6->Size = System::Drawing::Size(34, 33);
  392.             this->label6->TabIndex = 11;
  393.             this->label6->Text = L"Y";
  394.             //
  395.             // label5
  396.             //
  397.             this->label5->AutoSize = true;
  398.             this->label5->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  399.                 static_cast<System::Byte>(0)));
  400.             this->label5->Location = System::Drawing::Point(146, 157);
  401.             this->label5->Name = L"label5";
  402.             this->label5->Size = System::Drawing::Size(32, 33);
  403.             this->label5->TabIndex = 10;
  404.             this->label5->Text = L"X";
  405.             //
  406.             // label3
  407.             //
  408.             this->label3->AutoSize = true;
  409.             this->label3->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  410.                 static_cast<System::Byte>(0)));
  411.             this->label3->Location = System::Drawing::Point(249, 235);
  412.             this->label3->Name = L"label3";
  413.             this->label3->Size = System::Drawing::Size(37, 33);
  414.             this->label3->TabIndex = 9;
  415.             this->label3->Text = L"B";
  416.             //
  417.             // label4
  418.             //
  419.             this->label4->AutoSize = true;
  420.             this->label4->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  421.                 static_cast<System::Byte>(0)));
  422.             this->label4->Location = System::Drawing::Point(41, 235);
  423.             this->label4->Name = L"label4";
  424.             this->label4->Size = System::Drawing::Size(36, 33);
  425.             this->label4->TabIndex = 8;
  426.             this->label4->Text = L"A";
  427.             //
  428.             // label2
  429.             //
  430.             this->label2->AutoSize = true;
  431.             this->label2->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  432.                 static_cast<System::Byte>(0)));
  433.             this->label2->Location = System::Drawing::Point(249, 157);
  434.             this->label2->Name = L"label2";
  435.             this->label2->Size = System::Drawing::Size(37, 33);
  436.             this->label2->TabIndex = 7;
  437.             this->label2->Text = L"B";
  438.             //
  439.             // label1
  440.             //
  441.             this->label1->AutoSize = true;
  442.             this->label1->Font = (gcnew System::Drawing::Font(L"Papyrus", 15.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
  443.                 static_cast<System::Byte>(0)));
  444.             this->label1->Location = System::Drawing::Point(41, 157);
  445.             this->label1->Name = L"label1";
  446.             this->label1->Size = System::Drawing::Size(36, 33);
  447.             this->label1->TabIndex = 6;
  448.             this->label1->Text = L"A";
  449.             this->label1->Click += gcnew System::EventHandler(this, &EqForm::label1_Click);
  450.             //
  451.             // BYtxt
  452.             //
  453.             this->BYtxt->BackColor = System::Drawing::SystemColors::MenuText;
  454.             this->BYtxt->Font = (gcnew System::Drawing::Font(L"Papyrus", 9.75F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  455.                 static_cast<System::Byte>(0)));
  456.             this->BYtxt->ForeColor = System::Drawing::SystemColors::Menu;
  457.             this->BYtxt->Location = System::Drawing::Point(220, 206);
  458.             this->BYtxt->Name = L"BYtxt";
  459.             this->BYtxt->Size = System::Drawing::Size(100, 28);
  460.             this->BYtxt->TabIndex = 5;
  461.             //
  462.             // Y0txt
  463.             //
  464.             this->Y0txt->BackColor = System::Drawing::SystemColors::MenuText;
  465.             this->Y0txt->Font = (gcnew System::Drawing::Font(L"Papyrus", 9.75F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  466.                 static_cast<System::Byte>(0)));
  467.             this->Y0txt->ForeColor = System::Drawing::SystemColors::Menu;
  468.             this->Y0txt->Location = System::Drawing::Point(114, 206);
  469.             this->Y0txt->Name = L"Y0txt";
  470.             this->Y0txt->Size = System::Drawing::Size(100, 28);
  471.             this->Y0txt->TabIndex = 4;
  472.             //
  473.             // AYtxt
  474.             //
  475.             this->AYtxt->BackColor = System::Drawing::SystemColors::MenuText;
  476.             this->AYtxt->Font = (gcnew System::Drawing::Font(L"Papyrus", 9.75F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  477.                 static_cast<System::Byte>(0)));
  478.             this->AYtxt->ForeColor = System::Drawing::SystemColors::Menu;
  479.             this->AYtxt->Location = System::Drawing::Point(8, 206);
  480.             this->AYtxt->Name = L"AYtxt";
  481.             this->AYtxt->Size = System::Drawing::Size(100, 28);
  482.             this->AYtxt->TabIndex = 3;
  483.             //
  484.             // BXtxt
  485.             //
  486.             this->BXtxt->BackColor = System::Drawing::SystemColors::MenuText;
  487.             this->BXtxt->Font = (gcnew System::Drawing::Font(L"Papyrus", 9.75F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  488.                 static_cast<System::Byte>(0)));
  489.             this->BXtxt->ForeColor = System::Drawing::SystemColors::Menu;
  490.             this->BXtxt->Location = System::Drawing::Point(220, 128);
  491.             this->BXtxt->Name = L"BXtxt";
  492.             this->BXtxt->Size = System::Drawing::Size(100, 28);
  493.             this->BXtxt->TabIndex = 2;
  494.             //
  495.             // X0txt
  496.             //
  497.             this->X0txt->BackColor = System::Drawing::SystemColors::MenuText;
  498.             this->X0txt->Font = (gcnew System::Drawing::Font(L"Papyrus", 9.75F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  499.                 static_cast<System::Byte>(0)));
  500.             this->X0txt->ForeColor = System::Drawing::SystemColors::Menu;
  501.             this->X0txt->Location = System::Drawing::Point(114, 128);
  502.             this->X0txt->Name = L"X0txt";
  503.             this->X0txt->Size = System::Drawing::Size(100, 28);
  504.             this->X0txt->TabIndex = 1;
  505.             //
  506.             // AXtxt
  507.             //
  508.             this->AXtxt->BackColor = System::Drawing::SystemColors::MenuText;
  509.             this->AXtxt->Font = (gcnew System::Drawing::Font(L"Papyrus", 9.75F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  510.                 static_cast<System::Byte>(0)));
  511.             this->AXtxt->ForeColor = System::Drawing::SystemColors::Menu;
  512.             this->AXtxt->Location = System::Drawing::Point(8, 128);
  513.             this->AXtxt->Name = L"AXtxt";
  514.             this->AXtxt->Size = System::Drawing::Size(100, 28);
  515.             this->AXtxt->TabIndex = 0;
  516.             //
  517.             // pictureBox1
  518.             //
  519.             this->pictureBox1->BackColor = System::Drawing::Color::White;
  520.             this->pictureBox1->Location = System::Drawing::Point(6, 25);
  521.             this->pictureBox1->Name = L"pictureBox1";
  522.             this->pictureBox1->Size = System::Drawing::Size(512, 381);
  523.             this->pictureBox1->TabIndex = 6;
  524.             this->pictureBox1->TabStop = false;
  525.             //
  526.             // groupBox3
  527.             //
  528.             this->groupBox3->Controls->Add(this->textBox3);
  529.             this->groupBox3->Controls->Add(this->pictureBox1);
  530.             this->groupBox3->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
  531.                 static_cast<System::Byte>(204)));
  532.             this->groupBox3->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
  533.                 static_cast<System::Int32>(static_cast<System::Byte>(255)));
  534.             this->groupBox3->Location = System::Drawing::Point(344, 149);
  535.             this->groupBox3->Name = L"groupBox3";
  536.             this->groupBox3->Size = System::Drawing::Size(524, 444);
  537.             this->groupBox3->TabIndex = 7;
  538.             this->groupBox3->TabStop = false;
  539.             this->groupBox3->Text = L"THE RESULTS";
  540.             //
  541.             // textBox3
  542.             //
  543.             this->textBox3->Location = System::Drawing::Point(6, 412);
  544.             this->textBox3->Name = L"textBox3";
  545.             this->textBox3->Size = System::Drawing::Size(512, 26);
  546.             this->textBox3->TabIndex = 29;
  547.             //
  548.             // table
  549.             //
  550.             this->table->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
  551.             this->table->Location = System::Drawing::Point(874, 12);
  552.             this->table->Name = L"table";
  553.             this->table->Size = System::Drawing::Size(629, 581);
  554.             this->table->TabIndex = 8;
  555.             //
  556.             // pictureBox2
  557.             //
  558.             this->pictureBox2->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox2.BackgroundImage")));
  559.             this->pictureBox2->InitialImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox2.InitialImage")));
  560.             this->pictureBox2->Location = System::Drawing::Point(138, 30);
  561.             this->pictureBox2->Name = L"pictureBox2";
  562.             this->pictureBox2->Size = System::Drawing::Size(266, 31);
  563.             this->pictureBox2->TabIndex = 5;
  564.             this->pictureBox2->TabStop = false;
  565.             //
  566.             // pictureBox3
  567.             //
  568.             this->pictureBox3->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox3.BackgroundImage")));
  569.             this->pictureBox3->InitialImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox3.InitialImage")));
  570.             this->pictureBox3->Location = System::Drawing::Point(138, 62);
  571.             this->pictureBox3->Name = L"pictureBox3";
  572.             this->pictureBox3->Size = System::Drawing::Size(266, 31);
  573.             this->pictureBox3->TabIndex = 6;
  574.             this->pictureBox3->TabStop = false;
  575.             this->pictureBox3->WaitOnLoad = true;
  576.             //
  577.             // pictureBox4
  578.             //
  579.             this->pictureBox4->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox4.BackgroundImage")));
  580.             this->pictureBox4->InitialImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox4.InitialImage")));
  581.             this->pictureBox4->Location = System::Drawing::Point(138, 94);
  582.             this->pictureBox4->Name = L"pictureBox4";
  583.             this->pictureBox4->Size = System::Drawing::Size(266, 31);
  584.             this->pictureBox4->TabIndex = 7;
  585.             this->pictureBox4->TabStop = false;
  586.             this->pictureBox4->WaitOnLoad = true;
  587.             //
  588.             // pictureBox5
  589.             //
  590.             this->pictureBox5->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox5.BackgroundImage")));
  591.             this->pictureBox5->InitialImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox5.InitialImage")));
  592.             this->pictureBox5->Location = System::Drawing::Point(573, 30);
  593.             this->pictureBox5->Name = L"pictureBox5";
  594.             this->pictureBox5->Size = System::Drawing::Size(253, 44);
  595.             this->pictureBox5->TabIndex = 8;
  596.             this->pictureBox5->TabStop = false;
  597.             this->pictureBox5->WaitOnLoad = true;
  598.             //
  599.             // pictureBox6
  600.             //
  601.             this->pictureBox6->BackgroundImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox6.BackgroundImage")));
  602.             this->pictureBox6->InitialImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"pictureBox6.InitialImage")));
  603.             this->pictureBox6->Location = System::Drawing::Point(573, 81);
  604.             this->pictureBox6->Name = L"pictureBox6";
  605.             this->pictureBox6->Size = System::Drawing::Size(253, 39);
  606.             this->pictureBox6->TabIndex = 9;
  607.             this->pictureBox6->TabStop = false;
  608.             this->pictureBox6->WaitOnLoad = true;
  609.             //
  610.             // EqForm
  611.             //
  612.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  613.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  614.             this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(57)), static_cast<System::Int32>(static_cast<System::Byte>(23)),
  615.                 static_cast<System::Int32>(static_cast<System::Byte>(50)));
  616.             this->ClientSize = System::Drawing::Size(1515, 605);
  617.             this->Controls->Add(this->table);
  618.             this->Controls->Add(this->groupBox3);
  619.             this->Controls->Add(this->groupBox2);
  620.             this->Controls->Add(this->groupBox1);
  621.             this->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
  622.                 static_cast<System::Int32>(static_cast<System::Byte>(255)));
  623.             this->Name = L"EqForm";
  624.             this->Text = L"EqForm";
  625.             this->groupBox1->ResumeLayout(false);
  626.             this->groupBox1->PerformLayout();
  627.             this->groupBox2->ResumeLayout(false);
  628.             this->groupBox2->PerformLayout();
  629.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
  630.             this->groupBox3->ResumeLayout(false);
  631.             this->groupBox3->PerformLayout();
  632.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->table))->EndInit();
  633.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox2))->EndInit();
  634.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox3))->EndInit();
  635.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox4))->EndInit();
  636.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox5))->EndInit();
  637.             (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox6))->EndInit();
  638.             this->ResumeLayout(false);
  639.  
  640.         }
  641. #pragma endregion
  642. float E = 0.01;
  643. int sel_eq = 0;
  644. //EQ1, EQ2, EQ3
  645. float f(float x) {
  646.     if (sel_eq == 1)
  647.         return x * x * x + 2.28 * x * x - 1.934 * x - 3.907;
  648.     if (sel_eq == 2)
  649.         return x * x * x + 4.81 * x * x - 17.37 * x + 5.38;
  650.     if (sel_eq == 3)
  651.         return -(x * x * x) + 5.67 * x * x - 7.12 * x + 1.34;
  652. }
  653. float fd(float x) {
  654.     if (sel_eq == 1)
  655.         return 3 * x * x + 4.56 * x - 1.934;
  656.     if (sel_eq == 2)
  657.         return 3 * x * x + 9.62 * x - 17.37;
  658.     if (sel_eq == 3)
  659.         return -(3 * x * x) + 11.34 * x - 7.12;
  660. }
  661.  
  662.  
  663. //EQ4
  664. float ff_4(float x, float y) {
  665.     return 2 * x - sin(y - 0.5) - 1;
  666. }
  667. float gg_4(float x, float y) {
  668.     return y + cos(x) - 1.5;
  669. }
  670. float xc_4(float y) {
  671.     return (sin(y - 0.5) + 1) / 2;
  672. }
  673. float yc_4(float x) {
  674.     return 1.5 - cos(x);
  675. }
  676.  
  677. float dn11_4(float x, float y) {
  678.     return 2;
  679. }
  680. float dn12_4(float x, float y) {
  681.     return -cos(0.5 - y);
  682. }
  683. float dn21_4(float x, float y) {
  684.     return -sin(x);
  685. }
  686. float dn22_4(float x, float y) {
  687.     return 1;
  688. }
  689. //EQ5
  690. float ff_5(float x, float y) {
  691.     return sin(y+0.5)-x-1;
  692. }
  693. float gg_5(float x, float y) {
  694.     return y+cos(x-2);
  695. }
  696. float xc_5(float y) {
  697.     return sin(y+0.5)-1;
  698. }
  699. float yc_5(float x) {
  700.     return -cos(x-2);
  701. }
  702.  
  703. float dn11_5(float x, float y) {
  704.     return -1;
  705. }
  706. float dn12_5(float x, float y) {
  707.     return cos(y+0.5);
  708. }
  709. float dn21_5(float x, float y) {
  710.     return sin(2-x);
  711. }
  712. float dn22_5(float x, float y) {
  713.     return 1;
  714. }
  715.  
  716.  
  717. private: double to_double(System::String^ str) {
  718.     const char* chars = (const char*)(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str)).ToPointer();
  719.     std::string ss = chars;
  720.  
  721.     // Free the allocated memory for const char*
  722.     System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr((void*)chars));
  723.     std::istringstream iss(ss);
  724.     double result;
  725.     iss >> result;
  726.     return result;
  727. }
  728. private: double min(double a, double b) {
  729.     if (a < b) return a; else return b;
  730. }
  731. private: double max(double a, double b) {
  732.     if (a > b) return a; else return b;
  733. }
  734.  
  735. std::pair <float, float> solven(float x, float y) {
  736.     float aa, bb, cc, dd, ee, ff;
  737.     if (sel_eq == 4) {
  738.         aa = dn11_4(x, y);
  739.         bb = dn12_4(x, y);
  740.         cc = -ff_4(x, y);
  741.         dd = dn21_4(x, y);
  742.         ee = dn22_4(x, y);
  743.         ff = -gg_4(x, y);
  744.     }
  745.     else {
  746.         aa = dn11_5(x, y);
  747.         bb = dn12_5(x, y);
  748.         cc = -ff_5(x, y);
  749.         dd = dn21_5(x, y);
  750.         ee = dn22_5(x, y);
  751.         ff = -gg_5(x, y);
  752.     }
  753.  
  754.     float newx = 0;
  755.     float newy = 0;
  756.  
  757.     if (aa == 0 || dd == 0) {
  758.         if (aa == 0) {
  759.             newy = cc / bb;
  760.             newx = (ff - ee * newy) / dd;
  761.         }
  762.         else
  763.             if (dd == 0) {
  764.                 newy = ff / ee;
  765.                 newx = (cc - bb * newy) / aa;
  766.             }
  767.         return std::make_pair(newx, newy);
  768.     }
  769.  
  770.     if (bb == 0 || ee == 0) {
  771.         if (bb == 0) {
  772.             newx = cc / aa;
  773.             newy = (ff - dd * newx) / ee;
  774.         }
  775.         else
  776.             if (ee == 0) {
  777.                 newx = ff / dd;
  778.                 newy = (cc - aa * newx) / bb;
  779.             }
  780.         return std::make_pair(newx, newy);
  781.     }
  782.  
  783.  
  784.     if (aa != 0 && bb != 0 && dd != 0 && ee != 0) {
  785.         newy = (aa * ff - cc * dd) / (aa * ee - bb * dd);
  786.         newx = (cc - bb * newy) / aa;
  787.         return std::make_pair(newx, newy);
  788.     }
  789.     return std::make_pair(newx, newy);
  790. }
  791. std::pair <float, float> newton_2(float xa, float xb, float ya, float yb) {
  792.     table->ColumnHeadersVisible = true;
  793.     table->Columns->Clear();
  794.     table->Columns->Add("x", "x");
  795.     table->Columns->Add("y", "y");
  796.     table->Columns->Add("diff", "|x(k)-x(k-1)|");
  797.     table->Columns->Add("diff", "|y(k)-y(k-1)|");
  798.     float xp = xa;
  799.     float x = xa;
  800.     float yp = ya;
  801.     float y = ya;
  802.     int i = 0;
  803.     do {
  804.         xp = x;
  805.         yp = y;
  806.         std::pair <float, float> dxdy = solven(x, y);
  807.         x = xp + dxdy.first;
  808.         y = yp + dxdy.second;
  809.         table->Rows->Add();
  810.         table->Rows[i]->Cells[0]->Value = (x).ToString();
  811.         table->Rows[i]->Cells[1]->Value = (y).ToString();
  812.         table->Rows[i]->Cells[2]->Value = (x-xp).ToString();
  813.         table->Rows[i]->Cells[3]->Value = (y-yp).ToString();
  814.         i++;
  815.     } while (fabs(x - xp) > E && fabs(y - yp) > E);
  816.     return std::make_pair(x, y);
  817. }
  818.  
  819. float half_div(float a, float b) {
  820.     table->ColumnHeadersVisible = true;
  821.     table->Columns->Clear();
  822.     table->Columns->Add("a", "a");
  823.     table->Columns->Add("b", "b");
  824.     table->Columns->Add("x", "x");
  825.     table->Columns->Add("fa", "f(a)");
  826.     table->Columns->Add("fb", "f(b)");
  827.     table->Columns->Add("fx", "f(x)");
  828.     table->Columns->Add("abs", "|a-b|");
  829.     float x = 0, i=0;
  830.     do {
  831.         float x = (a + b) / 2;
  832.         table->Rows->Add();
  833.         table->Rows[i]->Cells[0]->Value = (a).ToString();
  834.         table->Rows[i]->Cells[1]->Value = (b).ToString();
  835.         table->Rows[i]->Cells[2]->Value = (x).ToString();
  836.         table->Rows[i]->Cells[3]->Value = (f(a)).ToString();
  837.         table->Rows[i]->Cells[4]->Value = (f(b)).ToString();
  838.         table->Rows[i]->Cells[5]->Value = (f(x)).ToString();
  839.         table->Rows[i]->Cells[6]->Value = (fabs(a - b)).ToString();
  840.         i++;
  841.         if (f(a) * f(x) < 0) b = x;
  842.         else
  843.             if (f(x) * f(b) < 0) a = x;
  844.     } while (fabs(a - b) > E);
  845.     return x;
  846. }
  847. float slicing(float x0, float x1) {
  848.     table->ColumnHeadersVisible = true;
  849.     table->Columns->Clear();
  850.     table->Columns->Add("ppx", "ppx");
  851.     table->Columns->Add("px", "px");
  852.     table->Columns->Add("x", "x");
  853.     table->Columns->Add("fx", "f(x)");
  854.     table->Columns->Add("abs", "|x-px|");
  855.     float i = 0;
  856.     float xn = x1;
  857.     float x = x0;
  858.     float px = x0;
  859.     do {
  860.         px = x;
  861.         x = xn;
  862.         xn = x - (x - px) / (f(x) - f(px)) * f(x);
  863.         table->Rows->Add();
  864.         table->Rows[i]->Cells[0]->Value = (px).ToString();
  865.         table->Rows[i]->Cells[1]->Value = (x).ToString();
  866.         table->Rows[i]->Cells[2]->Value = (xn).ToString();
  867.         table->Rows[i]->Cells[3]->Value = (f(x)).ToString();
  868.         table->Rows[i]->Cells[4]->Value = (fabs(xn-x)).ToString();
  869.         i++;
  870.     } while (fabs(xn - x) > E || f(xn) > E);
  871.     return xn;
  872. }
  873. float simple_iter(float a, float b) {
  874.     table->ColumnHeadersVisible = true;
  875.     table->Columns->Clear();
  876.     table->Columns->Add("px", "px");
  877.     table->Columns->Add("x", "x");
  878.     table->Columns->Add("fx", "f(x)");
  879.     table->Columns->Add("abs", "|x-px|");
  880.     float lam = 1 / max(fabs(fd(a)), fabs(fd(b)));
  881.     if (fd((a + b) / 2) > 0) lam = -lam;
  882.     float xn = a;
  883.     float x = a;
  884.     float i = 0;
  885.     do {
  886.         x = xn;
  887.         xn = xn + lam * f(x);
  888.         table->Rows->Add();
  889.         table->Rows[i]->Cells[0]->Value = (x).ToString();
  890.         table->Rows[i]->Cells[1]->Value = (xn).ToString();
  891.         table->Rows[i]->Cells[2]->Value = (f(xn)).ToString();
  892.         table->Rows[i]->Cells[3]->Value = (fabs(xn - x)).ToString();
  893.         i++;
  894.     } while (fabs(xn - x) > E);
  895.     return xn;
  896. }
  897. private: System::Void groupBox2_Enter(System::Object^ sender, System::EventArgs^ e) {
  898. }
  899. private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
  900. }
  901. private: System::Void label7_Click(System::Object^ sender, System::EventArgs^ e) {
  902. }
  903. private: System::Void textBox7_TextChanged(System::Object^ sender, System::EventArgs^ e) {
  904.     E = to_double(EPStext->Text);
  905. }
  906. private: System::Void label8_Click(System::Object^ sender, System::EventArgs^ e) {
  907. }
  908. private: void drawitall(float top, float bottom, float left, float right, bool surround) {
  909.     Graphics^ canvas = pictureBox1->CreateGraphics();
  910.     Color c_black = Color::FromName("Black");
  911.     Color c_white = Color::FromName("White");
  912.     Color c_green = Color::FromName("Green");
  913.     Color c_red = Color::FromName("Red");
  914.     canvas->Clear(c_white);
  915.     Pen ^greenPen = (gcnew Pen(c_green, 2.0));
  916.     Pen^ redPen = (gcnew Pen(c_red, 1.0));
  917.     Pen^ blackPen = (gcnew Pen(c_black, 1.0));
  918.  
  919.     Drawing::Font^ font = (gcnew Drawing::Font("Arial", 12));
  920.     Brush^ brush = Brushes::Black;
  921.     Brush^ brushr = Brushes::Red;
  922.  
  923.     SizeF textSize;
  924.  
  925.     float microrangex = 10;
  926.     if (fabs(right - left) < 10) microrangex = 1;
  927.     if (fabs(right - left) < 1) microrangex = 0.1;
  928.     if (fabs(right - left) < 0.1) microrangex = 0.01;
  929.     float microrangey = 10;
  930.     if (fabs(top - bottom) < 10) microrangey = 1;
  931.     if (fabs(top - bottom) < 1) microrangey = 0.1;
  932.     if (fabs(top - bottom) < 0.1) microrangey = 0.01;
  933.  
  934.     top += microrangey*2;
  935.     bottom -= microrangey * 2;
  936.     left -= microrangex * 2;
  937.     right += microrangex * 2;
  938.  
  939.     float x1 =  0;
  940.     float x2 =  0;
  941.     float y1 = -100;
  942.     float y2 = 100;
  943.     canvas->DrawLine(blackPen,
  944.         (x1 - left) / (right - left) * pictureBox1->Width,
  945.         (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height,
  946.         (x2 - left) / (right - left) * pictureBox1->Width,
  947.         (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  948.  
  949.     x1 = -100;
  950.     x2 = 100;
  951.     y1 = 0;
  952.     y2 = 0;
  953.     canvas->DrawLine(blackPen,
  954.         (x1 - left) / (right - left) * pictureBox1->Width,
  955.         (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height,
  956.         (x2 - left) / (right - left) * pictureBox1->Width,
  957.         (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  958.  
  959.     if (surround) {
  960.         x1 = -100;
  961.         x2 = 100;
  962.         y1 = top-microrangey*2;
  963.         y2 = bottom+microrangey * 2;
  964.         canvas->DrawLine(redPen,
  965.             (x1 - left) / (right - left) * pictureBox1->Width,
  966.             (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height,
  967.             (x2 - left) / (right - left) * pictureBox1->Width,
  968.             (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height);
  969.  
  970.         textSize = canvas->MeasureString((left + microrangex * 2).ToString("F2"), font);
  971.         canvas->DrawString((top - microrangey * 2).ToString("F2"), font, brushr,
  972.             0 * pictureBox1->Width,
  973.             (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height);
  974.  
  975.         canvas->DrawLine(redPen,
  976.             (x1 - left) / (right - left) * pictureBox1->Width,
  977.             (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height,
  978.             (x2 - left) / (right - left) * pictureBox1->Width,
  979.             (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  980.  
  981.         textSize = canvas->MeasureString((left + microrangex * 2).ToString("F2"), font);
  982.         canvas->DrawString((bottom + microrangey * 2).ToString("F2"), font, brushr,
  983.             0 * pictureBox1->Width,
  984.             (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  985.     }
  986.     x1 = left + microrangex * 2;
  987.     x2 = right - microrangex * 2;
  988.     y1 = -100;
  989.     y2 = 100;
  990.     canvas->DrawLine(redPen,
  991.         (x1 - left) / (right - left) * pictureBox1->Width,
  992.         (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height,
  993.         (x1 - left) / (right - left) * pictureBox1->Width,
  994.         (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  995.  
  996.     textSize = canvas->MeasureString((left + microrangex * 2).ToString("F2"), font);
  997.     canvas->DrawString((left + microrangex * 2).ToString("F2"), font, brushr,
  998.         (x1 - left) / (right - left) * pictureBox1->Width,
  999.         (1) * pictureBox1->Height - textSize.Height);
  1000.  
  1001.     canvas->DrawLine(redPen,
  1002.         (x2 - left) / (right - left) * pictureBox1->Width,
  1003.         (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height,
  1004.         (x2 - left) / (right - left) * pictureBox1->Width,
  1005.         (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  1006.  
  1007.     textSize = canvas->MeasureString((right - microrangex * 2).ToString("F2"), font);
  1008.     canvas->DrawString((right - microrangex * 2).ToString("F2"), font, brushr,
  1009.         (x2 - left) / (right - left) * pictureBox1->Width,
  1010.         (1) * pictureBox1->Height - textSize.Height);
  1011.  
  1012.     for (double x = -100; x <= 100; x += microrangex) {
  1013.  
  1014.         x1 = x;
  1015.         x2 = x;
  1016.         y1 = -microrangey/10;
  1017.         y2 = microrangey/10;
  1018.         canvas->DrawLine(blackPen,
  1019.             (x1 - left) / (right - left) * pictureBox1->Width,
  1020.             (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height,
  1021.             (x2 - left) / (right - left) * pictureBox1->Width,
  1022.             (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  1023.         textSize = canvas->MeasureString((x).ToString("F2"), font);
  1024.         canvas->DrawString((x).ToString("F2"), font, brush,
  1025.             (x1 - left) / (right - left) * pictureBox1->Width - textSize.Width / 2,
  1026.             (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height);
  1027.     }
  1028.     for (double y = -100; y <= 100; y += microrangey) {
  1029.         x1 = -microrangex/10;
  1030.         x2 = microrangex/10;
  1031.         y1 = y;
  1032.         y2 = y;
  1033.         canvas->DrawLine(blackPen,
  1034.             (x1 - left) / (right - left) * pictureBox1->Width,
  1035.             (1 - (y1 - bottom) / (top - bottom)) * pictureBox1->Height,
  1036.             (x2 - left) / (right - left) * pictureBox1->Width,
  1037.             (1 - (y2 - bottom) / (top - bottom)) * pictureBox1->Height);
  1038.         textSize = canvas->MeasureString((y).ToString("F2"), font);
  1039.         canvas->DrawString((y).ToString("F2"), font, brush,
  1040.             (x1 - left) / (right - left) * pictureBox1->Width,
  1041.             (1 - ((y1) - bottom) / (top - bottom)) * pictureBox1->Height-textSize.Height / 2);
  1042.     }
  1043.  
  1044.     if (sel_eq == 1 || sel_eq == 2 || sel_eq == 3) {
  1045.         float px = left;
  1046.         float py = f(px);
  1047.         for (float x = left+microrangex; x <= right + microrangex; x += microrangex/20) {
  1048.             float y = f(x);
  1049.  
  1050.             canvas->DrawLine(greenPen,
  1051.                 (px - left) / fabs(right - left) * pictureBox1->Width,
  1052.                 (1 - (py - bottom) / fabs(top - bottom)) * pictureBox1->Height,
  1053.                 (x - left) / fabs(right - left) * pictureBox1->Width,
  1054.                 (1 - (y - bottom) / fabs(top - bottom)) * pictureBox1->Height);
  1055.  
  1056.             px = x;
  1057.             py = y;
  1058.         }
  1059.     }
  1060.     if (sel_eq == 4){
  1061.         float px = left;
  1062.         float py = yc_4(px);
  1063.         for (float x = left + microrangex; x <= right + microrangex; x += microrangex / 20) {
  1064.             float y = yc_4(x);
  1065.  
  1066.             canvas->DrawLine(greenPen,
  1067.                 (px - left) / fabs(right - left) * pictureBox1->Width,
  1068.                 (1 - (py - bottom) / fabs(top - bottom)) * pictureBox1->Height,
  1069.                 (x - left) / fabs(right - left) * pictureBox1->Width,
  1070.                 (1 - (y - bottom) / fabs(top - bottom)) * pictureBox1->Height);
  1071.  
  1072.             px = x;
  1073.             py = y;
  1074.         }
  1075.         py = bottom;
  1076.         px = xc_4(py);
  1077.         for (float y = bottom + microrangey; y <= top+microrangey; y += microrangey / 5) {
  1078.             float x = xc_4(y);
  1079.  
  1080.             canvas->DrawLine(greenPen,
  1081.                 (px - left) / fabs(right - left) * pictureBox1->Width,
  1082.                 (1 - (py - bottom) / fabs(top - bottom)) * pictureBox1->Height,
  1083.                 (x - left) / fabs(right - left) * pictureBox1->Width,
  1084.                 (1 - (y - bottom) / fabs(top - bottom)) * pictureBox1->Height);
  1085.  
  1086.             px = x;
  1087.             py = y;
  1088.         }
  1089.     }
  1090. }
  1091. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  1092.     switch (method->SelectedIndex) {
  1093.         case 0: {
  1094.             try {
  1095.                 if (sel_eq > 3) {
  1096.                     textBox3->Text = "Cannot use the slicing method on this equation.";
  1097.                     break;
  1098.                 }
  1099.                 double x0 = to_double(X0txt->Text);
  1100.                 double x1 = to_double(Y0txt->Text);
  1101.                 int slt = 0;
  1102.                 for (float k = x0;k <= x1;k += 0.1) {
  1103.                     if (f(k) * f(k - 0.1) < 0) slt++;
  1104.                 }
  1105.                 if (slt == 0) {
  1106.                     textBox3->Text = "This range contains no solutions.";
  1107.                     break;
  1108.                 }
  1109.                 if (slt > 2) {
  1110.                     textBox3->Text = "This range contains multiple solutions.";
  1111.                     break;
  1112.                 }
  1113.                 slicing(x0, x1);
  1114.                 float fl = 999;
  1115.                 float cei = -999;
  1116.                 for (float k = x0;k <= x1;k += 0.1) {
  1117.                     fl = min(fl, f(k));
  1118.                     cei = max(cei, f(k));
  1119.                 }
  1120.                 drawitall(cei, fl, x0, x1, false);
  1121.             }
  1122.             catch (...) {
  1123.                 textBox3->Text = "Invalid input.";
  1124.             }
  1125.             break;
  1126.         }
  1127.         case 1: {
  1128.             try{
  1129.                 if (sel_eq > 3) {
  1130.                     textBox3->Text = "Cannot use the half-splitting method on this equation.";
  1131.                     break;
  1132.                 }
  1133.                 double a = to_double(AXtxt->Text);
  1134.                 double b = to_double(BXtxt->Text);
  1135.                 int slt = 0;
  1136.                 for (float k = a;k <= b;k += 0.1) {
  1137.                     if (f(k) * f(k - 0.1) < 0) slt++;
  1138.                 }
  1139.                 if (slt == 0) {
  1140.                     textBox3->Text = "This range contains no solutions.";
  1141.                     break;
  1142.                 }
  1143.                 if (slt > 2) {
  1144.                     textBox3->Text = "This range contains multiple solutions.";
  1145.                     break;
  1146.                 }
  1147.                 half_div(a, b);
  1148.                 float fl = 999;
  1149.                 float cei = -999;
  1150.                 for (float k = a;k <= b;k+=0.1) {
  1151.                     fl = min(fl, f(k));
  1152.                     cei = max(cei, f(k));
  1153.                 }
  1154.                 drawitall(cei, fl, a, b, false);
  1155.             }
  1156.             catch (...) {
  1157.                 textBox3->Text = "Invalid input.";
  1158.             }
  1159.             break;
  1160.         }
  1161.         case 2: {
  1162.             try {
  1163.                 if (sel_eq > 3) {
  1164.                     textBox3->Text = "Cannot use the simple iterations method on this equation.";
  1165.                     break;
  1166.                 }
  1167.                 double a = to_double(AXtxt->Text);
  1168.                 double b = to_double(BXtxt->Text);
  1169.                 int slt = 0;
  1170.                 for (float k = a;k <= b;k += 0.1) {
  1171.                     if (f(k) * f(k - 0.1) < 0) slt++;
  1172.                 }
  1173.                 if (slt == 0) {
  1174.                     textBox3->Text = "This range contains no solutions.";
  1175.                     break;
  1176.                 }
  1177.                 if (slt > 2) {
  1178.                     textBox3->Text = "This range contains multiple solutions.";
  1179.                     break;
  1180.                 }
  1181.                 simple_iter(a, b);
  1182.                 float fl = 999;
  1183.                 float cei = -999;
  1184.                 for (float k = a;k <= b;k+=0.1) {
  1185.                     fl = min(fl, f(k));
  1186.                     cei = max(cei, f(k));
  1187.                 }
  1188.                 drawitall(cei, fl, a, b, false);
  1189.                 break;
  1190.             }
  1191.             catch (...) {
  1192.                 textBox3->Text = "Method does not converge in this range.";
  1193.             }
  1194.             break;
  1195.         }
  1196.         case 3: {
  1197.             if (sel_eq < 4) {
  1198.                 textBox3->Text = "Cannot use the newton method on this equation.";
  1199.                 break;
  1200.             }
  1201.             double ax = to_double(AXtxt->Text);
  1202.             double bx = to_double(BXtxt->Text);
  1203.             double ay = to_double(AYtxt->Text);
  1204.             double by = to_double(BYtxt->Text);
  1205.             newton_2(ax, bx, ay, by);
  1206.             drawitall(by, ay, ax, bx, true);
  1207.             break;
  1208.         }
  1209.     }
  1210. }
  1211. private: System::Void label17_Click(System::Object^ sender, System::EventArgs^ e) {
  1212. }
  1213. private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
  1214.     switch (method->SelectedIndex) {
  1215.         case 0: {
  1216.             AXtxt->Hide();
  1217.             AYtxt->Hide();
  1218.             BXtxt->Hide();
  1219.             BYtxt->Hide();
  1220.             X0txt->Show();
  1221.             Y0txt->Show();
  1222.             label5->Text = "X0";
  1223.             label6->Text = "X1";
  1224.             label4->Show();
  1225.             label11->Show();
  1226.             label6->Show();
  1227.             label10->Show();
  1228.             label3->Show();
  1229.             break;
  1230.         }
  1231.         case 1: {
  1232.             AXtxt->Show();
  1233.             AYtxt->Hide();
  1234.             BXtxt->Show();
  1235.             BYtxt->Hide();
  1236.             X0txt->Hide();
  1237.             Y0txt->Hide();
  1238.             label5->Text = "X0";
  1239.             label4->Hide();
  1240.             label11->Hide();
  1241.             label6->Hide();
  1242.             label10->Hide();
  1243.             label3->Hide();
  1244.             break;
  1245.         }
  1246.         case 2: {
  1247.             AXtxt->Show();
  1248.             AYtxt->Hide();
  1249.             BXtxt->Show();
  1250.             BYtxt->Hide();
  1251.             X0txt->Hide();
  1252.             Y0txt->Hide();
  1253.             label5->Text = "X0";
  1254.             label4->Hide();
  1255.             label11->Hide();
  1256.             label6->Hide();
  1257.             label10->Hide();
  1258.             label3->Hide();
  1259.             break;
  1260.         }
  1261.         case 3: {
  1262.             AXtxt->Show();
  1263.             AYtxt->Show();
  1264.             BXtxt->Show();
  1265.             BYtxt->Show();
  1266.             X0txt->Hide();
  1267.             Y0txt->Hide();
  1268.             label5->Text = "X";
  1269.             label6->Text = "Y";
  1270.             label4->Show();
  1271.             label11->Show();
  1272.             label6->Show();
  1273.             label10->Show();
  1274.             label3->Show();
  1275.             break;
  1276.         }
  1277.     }
  1278. }
  1279. private: System::Void eqrb1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  1280.     sel_eq = 1;
  1281.     textBox3->Text = "Equation selected: " + (sel_eq).ToString();
  1282. }
  1283. private: System::Void eqrb2_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  1284.     sel_eq = 2;
  1285.     textBox3->Text = "Equation selected: " + (sel_eq).ToString();
  1286. }
  1287. private: System::Void eqrb3_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  1288.     sel_eq = 3;
  1289.     textBox3->Text = "Equation selected: " + (sel_eq).ToString();
  1290. }
  1291. private: System::Void eqrb4_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  1292.     sel_eq = 4;
  1293.     textBox3->Text = "Equation selected: " + (sel_eq).ToString();
  1294. }
  1295. private: System::Void eqrb5_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
  1296.     sel_eq = 5;
  1297.     textBox3->Text = "Equation selected: " + (sel_eq).ToString();
  1298. }
  1299. };
  1300. }
  1301.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement