Skip to main content
added 323 characters in body; Post Made Community Wiki
Source Link
Mike Honeychurch
  • 37.9k
  • 3
  • 90
  • 165

I'm not sure how robust this is. It is quick and dirty so to speak.

With[{abbrev := Sum[int[i], {i, 1, n$}]}, f[n_] := abbrev + y; g[n_] := abbrev^2 (*and so on*)] 

enter image description here

...but I think @kuba's link provides better alternatives.

Edit

Such an alternative includes:

Clear[f, g]; Module[{abbrev := Sum[int[i], {i, 1, n}]}, SetDelayed @@ {f[n_], abbrev + y}; g[n_] := abbrev^2] 

Where you do not have to modify the n with dollar signs. The explanation for why this works is given in the post by Mr Wizard and Leonid.

I'm not sure how robust this is. It is quick and dirty so to speak.

With[{abbrev := Sum[int[i], {i, 1, n$}]}, f[n_] := abbrev + y; g[n_] := abbrev^2 (*and so on*)] 

enter image description here

...but I think @kuba's link provides better alternatives

I'm not sure how robust this is. It is quick and dirty so to speak.

With[{abbrev := Sum[int[i], {i, 1, n$}]}, f[n_] := abbrev + y; g[n_] := abbrev^2 (*and so on*)] 

enter image description here

...but I think @kuba's link provides better alternatives.

Edit

Such an alternative includes:

Clear[f, g]; Module[{abbrev := Sum[int[i], {i, 1, n}]}, SetDelayed @@ {f[n_], abbrev + y}; g[n_] := abbrev^2] 

Where you do not have to modify the n with dollar signs. The explanation for why this works is given in the post by Mr Wizard and Leonid.

Source Link
Mike Honeychurch
  • 37.9k
  • 3
  • 90
  • 165

I'm not sure how robust this is. It is quick and dirty so to speak.

With[{abbrev := Sum[int[i], {i, 1, n$}]}, f[n_] := abbrev + y; g[n_] := abbrev^2 (*and so on*)] 

enter image description here

...but I think @kuba's link provides better alternatives