Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Clear[H]
- H[s_][x_, y_] :=
- f[x] + Piecewise[{{-1, s === "-"}}, 1]*g[y] /; s === "+" || s === "-"
- {H["+"][x, y], H["-"][x, y]}
- (* {f[x] + g[y], f[x] - g[y]} *)
- Clear[H]
- H[s_][x_, y_] := f[x] + Sign[s]*g[y] /; Abs[s] === 1
- {H[1][x, y], H[-1][x, y]}
- (* {f[x] + g[y], f[x] - g[y]} *)
- Needs["Notation´"]
- Symbolize[H±] (* Be careful to use the Writing Assistant palette or other formatting guides s.t. the definition actually displays like you want it to and not Subscript or similar means *)
- H±[x_, y_] := f[x] ± g[y] (* Same caveat about typesetting applies here as well *)
- In[1] := H±[1,2]
- Out[1]:= f[1]±g[2]
- h[op_Symbol][x_, y_] := op[f[x], g[y]]
- {h[Plus][m, n], h[Subtract][m, n], h[Times][m, n]}
- (* {f[m] + g[n], f[m] - g[n], f[m] g[n]} *)
- k[op_Symbol /; MemberQ[{Plus, Subtract}, op]][x_, y_] := op[f[x], g[y]]
- {k[Plus][m, n], k[Subtract][m, n], k[Times][m, n]}
- (* {f[m] + g[n], f[m] - g[n], k[Times][m, n]} *)
- (h:SubPlus|SubMinus)[H] ^:= With[
- {hh=Replace[h, {SubPlus->Plus, SubMinus->Subtract}]},
- hh[f[#1], g[#2]]&
- ]
- SubPlus[H][x, y]
- SubMinus[H][2, 3]
Add Comment
Please, Sign In to add comment