Message Boards Message Boards

0
|
4060 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Solve iteration for a cube root, by using For, While or Do?

Posted 6 years ago

You have a cube Root iteration:

Xi1 = 1/3(2Xi0 + n/(Xi0^2)), where i = 1,2,3,4,5

I want to use For, While or Do command...

How do I solve this?

POSTED BY: Zain Ahmed
6 Replies
Posted 6 years ago
Do[Print[1/3 (2 i + 8/(i^2))], {i, 1, 3}]
POSTED BY: Areeb Qureshi
Posted 6 years ago
For[i = 1, i < 4, i++, Print[1/3 (2 i + 8/(i^2))]]
POSTED BY: Areeb Qureshi
Posted 6 years ago

You know. how about Do Command instead?

POSTED BY: Zain Ahmed
Posted 6 years ago

Is there anyone else like here

KubikRod[x_Real?Positive] := Module[{i, a, n},
  n = x;
  a = 1/3 (2 i + (x/2)/i^2);
  While[a != i, i = a; a = 1/3 (2 i + (x/2)/i^2)]; a
  ]
POSTED BY: Zain Ahmed

I would try NestList, which is designed precisely for iterations:

step[Xi_] := 1/3 (2 Xi + n/(Xi^2));
NestList[step, 1, 3]
NestList[step, 1, 3] /. n -> 8.
POSTED BY: Gianluca Gorni
Posted 6 years ago

Yea I know, but I want to use command: Do, For or While.

POSTED BY: Zain Ahmed
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract