kill(all)$

g(x):=(x-3)/(x+1);

h(x):=(x+3)/(1-x);

ratsimp(g(h(x)));

ratsimp(h(g(x)));

(h(g(x))+g(h(x)))/2;

ratsimp(%);

f(x):=4*x/(1-x^2)-x/2;

ratsimp(f(x));

f(g(x))+f(h(x));

ratsimp(%);