Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int FoundN(AreaType areaType, double tolerantion)
- {
- int n = 1;
- double integral = 0;
- while (n <= MAX_N)
- {
- if (areaType == AreaType.Rectangle)
- integral = RectangleMethod(X1, X2, n);
- if (areaType == AreaType.Trapezoid)
- integral = TrapezoidMethod(X1, X2, n);
- double difference = Math.Abs(INTEGRAL_VALUE - integral);
- double differenceInPercent = (difference / Result.INTEGRAL_VALUE) * 100.0;
- if (differenceInPercent <= tolerantion)
- {
- break;
- }
- n++;
- }
- return n;
- }
- private static double DegreeToRadian(double angle)
- {
- return Math.PI * angle / 180.0;
- }
- private static double Function(double x)
- {
- return Math.Cos(DegreeToRadian(x));
- }
- //button
- tolerantion = Convert.ToDouble(numericUpDown2.Value);
- textBox1.Text = Convert.ToString(Result.FoundN(AreaType.Rectangle, tolerantion));
- textBox2.Text = Convert.ToString(Result.FoundN(AreaType.Trapezoid, tolerantion));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement