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?
{"ft_lang_label":"__label__en","ft_lang_prob":0.89223564,"math_prob":0.9086767,"size":1680,"snap":"2020-34-2020-40","text_gpt3_token_len":473,"char_repetition_ratio":0.09009547,"word_repetition_ratio":0.020547945,"special_character_ratio":0.30357143,"punctuation_ratio":0.13105413,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9929594,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-06T13:56:17Z\",\"WARC-Record-ID\":\"<urn:uuid:ee9b3b5b-5bb7-48e0-9a3d-d5d9434295d4>\",\"Content-Length\":\"45146\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e68ec102-30d5-43fb-8207-650a034426bb>\",\"WARC-Concurrent-To\":\"<urn:uuid:b9e1fd1c-04c1-49f4-ae8d-544f1bb5066e>\",\"WARC-IP-Address\":\"140.177.205.73\",\"WARC-Target-URI\":\"http://forums.wolfram.com/mathgroup/archive/1997/May/msg00028.html\",\"WARC-Payload-Digest\":\"sha1:FKIB2XKMINKATK7KKDAMIDEJRLAF3C6W\",\"WARC-Block-Digest\":\"sha1:CDNN5WGD566F3V3W4T2DOQMEMGJTRYMB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439736962.52_warc_CC-MAIN-20200806121241-20200806151241-00337.warc.gz\"}"}