MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: f + g

  • To: mathgroup at
  • Subject: [mg7574] Re: [mg7120] f + g
  • From: "C. Woll" <carlw at>
  • Date: Sun, 15 Jun 1997 16:33:05 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On Sun, 11 May 1997, Murray Eisenberg wrote:

> In mathematics, we define the sum f + g of two arbitrary real-valued
> functions f and g (with the same domain) by the rule (f + g)(x) = f(x)
> + g(x), so that, for example, (cos + exp)(0) = 2.  Similarly, for a
> constant c and an arbitrary function f we define the product cf by the
> rule (cf)(x) = c (f(x)).  [Generalizations to other kinds of values
> and to other operations, such as the product of two functions, are
> possible but not of interest to me in this question.)
> My question is:  is there some way directly to express this in
> Mathematica (3.0)?  That is, I would like to input
>    (Cos + Exp)[0]
> and get result 2 -- WITHOUT having to give first a specific rule for
> the sum of that particular pair of functions.  The sort of thing I
> have in mind is a general rule such as
>     (f_ + g_)[x_] := f[x] + g[x]
> but that certainly won't be acceptable to Mathematica (Tag Plus is
> Protected!)
> The only thing I could come up with was:
>    Unprotect[Plus]
>    (f_ + g_)[x_] := f[x] + g[x]
>    Protect[Plus]
> But I find that most unsatisfactory: it seems to me that such a basic,
> common operation in mathematics ought to be directly accessible in "a
> software system for doing mathematics"!
> ...

Hi Murray, 

Since this message is now old, I don't know if you're interested in it
anymore, but how about this approach, sort of combining your approach with
Through as suggested by Steve Luttrell. Thus,


Now, you can define a new function h in terms of other functions f and g

h := f :c+: g

where :c+: is the alias for the infix form of CirclePlus. This method
works for both pure functions and regular functions.


  • Prev by Date: DistinctElements.m package
  • Next by Date: We want to have characteristic equation of 3x3 matrix ....
  • Previous by thread: DistinctElements.m package
  • Next by thread: We want to have characteristic equation of 3x3 matrix ....