/// <summary> /// x[n] の式を生成します。 /// </summary> private void MainEquation() { Rational f = 1; string var = string.Format("f[{0}]", ORDER - 1); string exp = var; for (int i = 1; i < ORDER; i++) { f /= (i + 1); var = "h" + var + "'"; exp += "+" + f.ToString() + " " + var; } e_f = Expression.EasyParse(exp); }
//=========================================================== // 計算 //=========================================================== /// <summary> /// 式を生成します。 /// </summary> private void InitializeEquations() { string exp = "-f[{0}]+f[{1}]"; Rational f = 1; string var = "f[{1}]"; for (int i = 1; i < ORDER; i++) { f /= i; var = "h" + var + "'"; exp += "+" + f.ToString() + " " + var; } for (int i = ORDER - 2; i >= 0; i--) { equations[i] = Expression.EasyParse(string.Format(exp, i + 1, i)); } }
/// <summary> /// 式を f[n-1]^(m) で表し直します。 /// </summary> private void UpdatePastDifferentials() { build.Append("<ul>\r\n"); string var = "f[{0}]"; for (int n = 1; n < ORDER; n++) { var = "h" + var + "'"; // 代入する式の書式文字列を生成 Rational f2 = 1; string var2 = var; string exp2 = var; for (int m = 1; m < ORDER - n; m++) { f2 /= -m; var2 = "h" + var2 + "'"; exp2 += "+" + f2.ToString() + " " + var2; } // 式を表示 for (int i = 0; i <= ORDER - 2; i++) { string varname = string.Format(var, i); Expression x = Expression.EasyParse(string.Format(exp2, i + 1)); for (int j = 0; j < equations.Length; j++) { equations[j] = equations[j].Substitute(varname, x); } //---------- build.Append("<li>"); build.Append(Expression.EasyParse(varname).ToHtml(true)); build.Append(" = "); build.Append(x.ToHtml(true)); build.Append(" + O(h<sup>" + ORDER.ToString() + "</sup>)</li>\r\n"); } } build.Append("</ul>\r\n"); }