# Can I add two functions?

If I have $f(x,y)=2x+y^2$ and $g(x,y,z)=x+y+z$, is addition a valid operation?

I.e. $f(x,y)+g(x,y,z)=y^2+3x+y+z$?

• Well, it's not clear what you mean by that. Is the left hand a function of three variables? You could certainly define $F(x,y,z)=f(x,y)$ and then add $F$ and $g$ (getting the formula your wrote). But it's not obvious that this is what you intend. – lulu Sep 3 '17 at 14:37

Technically, no. Your first is a function $f: \mathbb{R}^2 \to \mathbb{R}$ while your second is a map $g: \mathbb{R}^3 \to \mathbb{R}$. As their domains are different, you can't add them. You can of course cheat by defining $f: \mathbb{R}^3 \to \mathbb{R}$ as $f(x,y,z) = 2x+y^2$ and then add them. You should consider if that changes your analysis, though.

Function addition is defined as $(f+g)(\vec x):=f(\vec x)+g(\vec x)$. So $(f+g)$ is undefined if $f$ has domain $\Bbb R^2$ and $g$ has domain $\Bbb R^3$. So you can redefine $f$ from $f(x,y)=2x+y^2$ to $f(x,y,z)=2x+y^2$, then in that case you can add these functions.

• The $:=$ should be the other way around, $f(x)+g(x)$ is already defined as it's just real number addition, $f+g$ is what needs to be defined. – YoTengoUnLCD Sep 3 '17 at 16:05
• @YoTengoUnLCD good point. I was just trying to show that the two expressions are the same. – Dave Sep 3 '17 at 16:06
• @YoTengoUnLCD Then wouldn't OP be correct then? – Andrew Tawfeek Sep 3 '17 at 17:00
• @AndrewTawfeek nope. In my definition of $f+g$ it is assumed that $x$ is in the domain of both $f,g$, else, the expression $f(x)$ makes no sense. – YoTengoUnLCD Sep 3 '17 at 17:02
• @AndrewTawfeek I see your confusion, but the function addition also relies on the domains being the same, which is not the case when $f$ is only over $\Bbb R^2$. – Dave Sep 3 '17 at 17:02

Adding together the values of two real-valued functions as you have done is certainly allowed.

If you want to define a new function that's the sum of the first two, then the domain, as noted by @Dave, must be the same, and the codomain must have a notion of addition (which $\Bbb R$ does, of course), so in this case, you cannot add functions (because of the first constraint)