Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace ConsoleApplication1
- {
- class Program
- {
- static double fun(double A, double B, double C, double D, double x)
- {
- return A * x + B*Math.Sqrt(x*x*x) - C * Math.Exp(-x / 50) - D;
- }
- static double czek(double A, double B, double C, double D)
- {
- double a = 0;
- double b = 100;
- double xMid = 1;
- double fmid;
- double check = 1;
- while (check != 0)
- {
- xMid = (a + b) / 2.0;
- fmid = fun(A, B, C, D, xMid);
- if (fmid < 0) a = xMid;
- else b = xMid;
- check = (Int64)(fmid * 100000000);
- }
- return xMid;
- }
- static void Main(string[] args)
- {
- double test = czek(0.59912051,0.64030348,263.33721367,387.92069617);
- double ShouldBe = 73.595368554162;
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement