This problem needs to be solved in matlab using a custom fun

This problem needs to be solved in matlab using a custom function, cant quite figure out

function phi = prob2_6(n) is the start of the custom function

test cases:
n = 5 -> phi = 1.618034154176712
n= 10 -> phi = 1.618033988674355
n= 50 -> phi = 1.618033988749895 (cases to try for n)

(18) The golden ratio, , can be approximated by a summation as shown belovw. Given a positive scalar integer n, create a function (prob2_6.m) to calculate the scalar sum of the first n terms of the series defined by: 13 (-1)n+1(2n + 1)! Your function needs to work only for integers values of 1 n 50 Hint: use the FACTORIAL function. Be sure to use \" and Use the suM function and make a vector that goes from 0n where appropriate. SUM

Solution

function phi =prob2_6(n)
format long
k=0:n;
phi1=((((-1).^(k+1)).*factorial(2.*k+1))./(factorial(k+2).*factorial(k).*(16.^(k+1))));
phi=sum(phi1);
phi=phi+(13./8);

This problem needs to be solved in matlab using a custom function, cant quite figure out function phi = prob2_6(n) is the start of the custom function test case

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site