[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Matlab/Numerical Methods
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /sci/ - Science & Math

Thread replies: 7
Thread images: 2
File: P4MatLab.png (55 KB, 837x717) Image search: [Google]
P4MatLab.png
55 KB, 837x717
Any MatLab Geniuses out there. I am completely lost on how to solve this. I think I need to use a while loop. Any help would really be appreciated.
>>
File: 1442068382496.jpg (26 KB, 353x334) Image search: [Google]
1442068382496.jpg
26 KB, 353x334
while pival-pi >err?
>>
>>7811091
>matlab geniuses
>approximating via series
toppu kekku

Yeah, you do need to use a while loop.

In informal terms, you're doing this

while |(pi - piVal) / (pi) * 100| > err

add another term to the approximation
increment my location in the series


when that's done you return your last piVal and how many terms you needed
>>
God, yall are better help than my teacher.
>>
>>7811091
It should be something like this:

Difference = 1;
Previous = 0;
Next = 1;
Precision = DESIRED NUMBER OF DECIMAL PLACES OF PI;

while Difference > 0
Current = Previous + (4/Next) - (4/(Next+2));
Difference = floor(Current*(10^Precision)) - floor(Previous*(10^Precision));
end
disp(Current);
>>
>>7811550
Oh, and some part of the while loop where you increment Next by 4 each time it loops.
Can't be bothered checking it in matlab, but it should hopefully work.
>>
>>7811550
>>7811552
i think this loop could work

while Difference > 0
Current = Previous + (4/Next) - (4/(Next+2));
Difference = floor(Current*(10^Precision)) - floor(Previous*(10^Precision));
Next=Next+4;
Previous=Current;
end
Thread replies: 7
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.