public override float findRoot(Segment ab, Interpolation F, float X, float e) { float a = ab.a; float b = ab.b; float fa, fb, fc; //N = 0; while (true) { fa = F.Calc(a, new LagrangeMethod()) - X; fb = F.Calc(b, new LagrangeMethod()) - X; fc = F.Calc((a + b) / 2.0f, new LagrangeMethod()) - X; if ((b - a) < 2 * e) break; if (fc == 0) break; // System.Console.WriteLine("x = {0} {1}", b-a, 2 * e); // N++; if (fa * fc < 0) b = (a + b) / 2.0f; else a = (a + b) / 2.0f; } return (a + b) / 2.0f; }
public abstract float findRoot(Segment ab, Interpolation F, float X, float e);