Numerical Methods Problem Solution

7 views (last 30 days)
Can i please get help with this question? I am new to MATLAB and do not know how to go about solving this in MATLAB, maybe i would be able to solve subsequest problems when i see the steps to this question. Thanks.
  4 Comments
Dyuman Joshi
Dyuman Joshi on 15 May 2021
Fair enough, I'll give you an outline of the code so you can work with it. In case you have any queries, do mention.
Chijioke  Nkwocha
Chijioke Nkwocha on 15 May 2021
I was able to come up with a code for the aforementioned problem, but i doubt it is right. Any idea to make it better?

Sign in to comment.

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 15 May 2021
Edited: Dyuman Joshi on 15 May 2021
In MATLAB, indexing start with 1 and not 0 (as it does in some programming languages).
%defining the initial values
t0 = 1/sqrt(3);
t = (sqrt(t0^2+1)-1)/t0;
pi_approx = (sqrt(t^2+1)-1)/t;
for i=1:24
t(i+1) = (sqrt(t(i)^2+1)-1)/t(i);
pi_approx(i+1) = 6*2^i*t(i+1);
end
%converting to table
y=array2table([t;pi_approx]', 'VariableNames',{'t','pi_approx'});
  5 Comments
Dyuman Joshi
Dyuman Joshi on 15 May 2021
I have edited my answer, check it.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!