Continued fractions take the following form

<

http://octave.1599824.n4.nabble.com/file/t371797/Screenshot_2017-09-14_17-43-33.png>

where a 1 is an integer and a 2 , a 3 , . . . , a n are positive integers.

Many of the most famous

irrational numbers can be expressed as infinite continued fraction

expansions. Truncating

these expansions after a relatively few terms often gives an excellent

approximation to the

irrational number.

(a) Write a function that computes the continued fraction expansion for a

given array (or

vector) of numbers a j , j = 1, 2, . . . , n. Your code should take as input

an array containing

the continued fraction coefficients a j and return the value x using formula

in (1).

here is my code so far:

clc

n = 8;

p = '1';

for r = 1:n;

p = (r+(1/r))

end

I know I need to write a function, but I'm starting simple.

--

Sent from:

http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html_______________________________________________

Help-octave mailing list

[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave