Skip to content

Instantly share code, notes, and snippets.

Created January 3, 2018 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/498da5e79bafe2c7a6928d0c3aa6fe3e to your computer and use it in GitHub Desktop.
Save anonymous/498da5e79bafe2c7a6928d0c3aa6fe3e to your computer and use it in GitHub Desktop.
Module[{g, d, \[Eta], m = 4, order = 3},
\[Eta] = u s/h;
(*d[x_]:=0;*)
(*d[x_]:=(f[0,x+h/2]-f[0,x-h/2])/h;*)
d[x_] := (2 - \[Eta])/3*(f[0, x + h/2] - f[0, x - h/2])/h + (1 + \[Eta])/3*(f[0, x - h/2] - f[0, x - 3 h/2])/h;
g[x_] := f[0, x - h/2] + 1/2 (1 - \[Eta]) h d[x];
Series[
(f[s, h/2] - f[0, h/2])/s + u (g[h] - g[0])/h
, {s, 0, m}, {h, 0, m}] // Normal // Expand
// ReplaceRepeated[#, {
Derivative[j_, k_][f][0, 0] :> Subscript[\[Alpha], j, k],
Subscript[\[Alpha], 0, k_] :> Subscript[\[Alpha], k],
Subscript[\[Alpha], j_,
k_] :> -u Subscript[\[Alpha], j - 1, k + 1]
}] &
]
Collect[% /. s -> h \[Eta]/u, h, Simplify]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment