We need g(f(x)) to be continuous for all x∈R. First, note that f(x)=x+a for x<0 and f(x)=∣x−1∣ for x≥0.
For x<0: f(x)=x+a. If a≥0, then as x→0−, f(x)→a≥0. For x sufficiently negative, f(x)<0. The transition happens at x=−a.
For x<−a: f(x)=x+a<0, so g(f(x))=f(x)+1=x+a+1. For −a≤x<0: f(x)=x+a≥0, so g(f(x))=(f(x)−1)2+b=(x+a−1)2+b. For x≥0: f(x)=∣x−1∣≥0, so g(f(x))=(∣x−1∣−1)2+b.
Checking continuity at x=−a: From the left, g(f(−a−))=−a+a+1=1. From the right, g(f(−a+))=(−a+a−1)2+b=1+b. For continuity: 1=1+b, so b=0.
Checking continuity at x=0: From the left (with −a≤x<0), g(f(0−))=(0+a−1)2+b=(a−1)2. From the right, g(f(0+))=(∣0−1∣−1)2+b=(1−1)2+0=0. For continuity: (a−1)2=0, so a=1.
Therefore a+b=1+0=1.
The answer is 1.