program for continued fractions without using rat

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

program for continued fractions without using rat

naryana.shankara
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
Reply | Threaded
Open this post in threaded view
|

Re: program for continued fractions without using rat

siko1056
Do you have a question regarding the usage of Octave or did you just get the
wrong e-mail address to submit your homework? ;-)

Kai.



--
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