Problem 5387. Triple function composition

Solution 2221944

Submitted on 19 Apr 2020 by Yaroslav Br
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   Pass
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))

y = function_handle with value: @(x)f(g(h(x)))

2   Pass
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)

y = function_handle with value: @(x)f(g(h(x)))

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!