[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
program for continued fractions without using rat
From: |
naryana.shankara |
Subject: |
program for continued fractions without using rat |
Date: |
Thu, 14 Sep 2017 16:47:27 -0700 (MST) |
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
- program for continued fractions without using rat,
naryana.shankara <=