# A Simple Correction Algorithm for a four-time Equation

Source: Internet
Author: User

// This program is based on the. NET platform and the compiling environment is Microsoft Visual C ++. net.
// To modify the VC ++ 6.0 platform, you only need to replace stdafx. h with iostream. h, and then remove the "using namespace STD" in the main function"
# Include "stdafx. H"
# Include "math. H"
Using namespace STD;
Double du, DV;

Void solu_w (double B, double C)
{
Double TEM, tem1;
Tem1 = B * B-4 * C;
Double M, N;
M = (-1) * B/2;
If (tem1> = 0)
{
TEM = SQRT (tem1 );
N = TEM/2;
Cout <"/n equation root: "<'/N' <"/T X1 = "<m + n <'/N' <"/T X2 = "<m-n <<Endl;
}
Else
{
TEM = SQRT (-1) * tem1 );
N = TEM/2;
Cout <"/n equation root: "<'/N' <"/T X1 = "<m <" + "<n <" I "<'/N' <" /t X2 = "<m <"-"<n <" I "<'/N' <Endl;
}
}
Void get_du_dv (double A, double B, double C, double D, double E, double F)
{
DV = (B * D-A * E)/(C * E-B * F );
Du = (C * D-A * f)/(B * F-C * E );
}

Void main ()
{
Cout <"coefficients of the input four equations" <Endl;
Double A ;
Double temp;
For (int t = 4; t> = 0; t --)
{
Cout <"/t a [" <t <"] = ";
Cin> temp;
A [T] = temp;
}
Cout <"/n equation:/n/t" <A  <"(x) + "<A  <" (x) + ";
Cout <A  <"(x * x) +" <A  <"(X) + "<A  <" = 0 "<'/N' <Endl;
Double U, V;
Cout <"constant and one-time coefficient of input factor:" <Endl;
Cout <"/t u = ";
Cin> U;
Cout <"/T v = ";
Cin> V;
Cout <"/N factor formula:/n/t w (x) =" <"(x * x) +" <u <"(X) + "<v <Endl;

Double P0, P1, P2, R0, R1;

Cout <"/N input correction times :";
Int count1;
Cin> count1;

For (count1; count1> = 0; count1 --)
{
P2 = A ;
P1 = A -u * P2;
P0 = A -V * p2-u * P1;

R0 = A -V * p1-u * P0;
R1 = A -V * P0;

// The following line is added to the program, causing the problem: if the number of corrections is too large, the program running time is greatly extended, and the main time is consumed on the screen.
// Cout <"/t p (x) =" <P2 <"(x * x) +" <P1 <"(X) + "<P0 <" = 0 "<Endl;

Double PP3, PP2, PP1, pp0, r0v, r1v, r0u, r1u;
PP3 = (-1) * P2;
PP2 = (-1) * P1;
PP1 = (-1) * P0;
Pp0 = 0;

R0v = u * P2-P1;
R1v = V * p2-p0;
R0u = r1v-u * r0v;
R1u = (-1) * V * r0v;

Get_du_dv (r0, r0u, r0v, R1, r1u, r1v );

U = u + du;
V = V + DV;
}

Solu_w (u, v );
}

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.