       f + g

• To: mathgroup at smc.vnet.net
• Subject: [mg7120] f + g
• From: murray at math.umass.edu (Murray Eisenberg)
• Date: Sun, 11 May 1997 02:57:18 -0400 (EDT)
• Organization: University of Massachusetts, Amherst
• Sender: owner-wri-mathgroup at wolfram.com

```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)

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"!

Any other ways except the above, which I regard as something of a
kludge?

--
Murray Eisenberg                       Internet:  murray at math.umass.edu
Mathematics & Statistics Dept.            Voice:  413-545-2859 (W)
University of Massachusetts                       413-549-1020 (H)
Amherst, MA 01003                           Fax:  413-545-1801

```

• Prev by Date: Re: Graphics`Graphics3D`Shadow
• Next by Date: Re: scaling 3D axes?