Cody

# Problem 5387. Triple function composition

Solution 3904243

Submitted on 29 Nov 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
f= @(x) x+1; g= @(x) x/2; h= @(x) x^2; x1 = 8 ; x2 = 10; x3=1; y1 = 33; y2 = 51; y3=1.5; y=compose3(f,g,h); assert(isequal(y(x1),y1)) assert(isequal(y(x2),y2)) assert(isequal(y(x3),y3))

Error using / Arguments must be numeric, char, or logical. Error in Test1>@(x)x/2 (line 2) g= @(x) x/2; Error in compose3 (line 2) f(g(h)) Error in Test1 (line 9) y=compose3(f,g,h);

2   Fail
f= @(x) log(x); g= @(x) x+6; h= @(x) x/2; x1 = 8 ; x2 = 4.4; x3 = 6; y1 = 2.3026; y2 = 2.1041; y3=2.1972; y=compose3(f,g,h); assert(abs(y(x1)-y1)<=1e-4) assert(abs(y(x2)-y2)<=1e-4) assert(abs(y(x3)-y3)<=1e-4)

Undefined function 'plus' for input arguments of type 'function_handle'. Error in Test2>@(x)x+6 (line 2) g= @(x) x+6; Error in compose3 (line 2) f(g(h)) Error in Test2 (line 9) y=compose3(f,g,h);

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!