private static void trinomial_test() //****************************************************************************80 // // Purpose: // // TRINOMIAL_TEST tests TRINOMIAL. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 April 2015 // // Author: // // John Burkardt // { int k; Console.WriteLine(""); Console.WriteLine("TRINOMIAL_TEST"); Console.WriteLine(" TRINOMIAL evaluates the trinomial coefficient:"); Console.WriteLine(""); Console.WriteLine(" T(I,J,K) = (I+J+K)! / I! / J! / K!"); Console.WriteLine(""); Console.WriteLine(" I J K T(I,J,K)"); Console.WriteLine(""); for (k = 0; k <= 4; k++) { int j; for (j = 0; j <= 4; j++) { int i; for (i = 0; i <= 4; i++) { int t = Trinomial.trinomial(i, j, k); Console.WriteLine(" " + i.ToString(InvariantCulture).PadLeft(4) + " " + j.ToString(InvariantCulture).PadLeft(4) + " " + k.ToString(InvariantCulture).PadLeft(4) + " " + t.ToString(InvariantCulture).PadLeft(8) + ""); } } } }
public List <TrinomialSolutionDto> Trinomial(Trinomial trinomial) { var solution = _algebra.Trinomial(trinomial.Equation, trinomial.A, trinomial.B, trinomial.C); return(solution); }
public static double[] poly_power_linear(int d1, double[] p1, int n) //****************************************************************************80 // // Purpose: // // POLY_POWER_LINEAR computes the polynomial ( a + b*x + c*y ) ^ n. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 21 April 2015 // // Author: // // John Burkardt // // Parameters: // // Input, int D1, the degree of the linear polynomial, // which should be 1 (or possibly 0). // // Input, double P1(M1), the coefficients of the linear polynomial. // M1 = ( (D1+1)*(D1+2) ) / 2, which should be 3. // // Input, int N, the power to which the polynomial is to be // raised. 0 <= N. // // Output, double P2(M2), the coefficients of the power polynomial. // D2 = N * D1; // M2 = ( (D2+1)*(D2+2) ) / 2. // { int i; switch (d1) { case < 0: Console.WriteLine(""); Console.WriteLine("POLY_POWER_LINEAR - Fatal error!"); Console.WriteLine(" D1 < 0."); return(null); } switch (n) { case < 0: Console.WriteLine(""); Console.WriteLine("POLY_POWER_LINEAR - Fatal error!"); Console.WriteLine(" N < 0."); return(null); } int d2 = n * d1; int m2 = (d2 + 1) * (d2 + 2) / 2; double[] p2 = new double[m2]; switch (d1) { case 0: p2[0] = Math.Pow(p1[0], n); return(p2); } switch (n) { case 0: p2[0] = 1.0; return(p2); } // // Use the Trinomial formula. // for (i = 0; i <= n; i++) { int j; for (j = 0; j <= n - i; j++) { int k; for (k = 0; k <= n - i - j; k++) { // // We store X^J Y^K in location L. // int l = pascal_to_i4(j, k); p2[l - 1] = Trinomial.trinomial(i, j, k) * Math.Pow(p1[0], i) * Math.Pow(p1[1], j) * Math.Pow(p1[2], k); } } } return(p2); }