MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / main

Function main

codes/cpp/Code_4_03_1.cpp:4–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4int main() {
5 double r = 2.0; // ��2 �����߂�������
6 double a = 2.0; // �����l��K���� 2.0 �ɃZ�b�g����
7
8 for (int i = 1; i <= 5; i++) {
9 // �_ (a, f(a)) �� x ���W�� y ���W�����߂�
10 double zahyou_x = a;
11 double zahyou_y = a * a;
12
13 // �ڐ��̌X�������߂� [y = (sessen_a)x + sessen_b �Ƃ���]
14 double sessen_a = 2.0 * zahyou_x;
15 double sessen_b = zahyou_y - sessen_a * zahyou_x;
16
17 // ���� a �̒l next_a �����߂�
18 double next_a = (r - sessen_b) / sessen_a;
19 printf("Step #%d: a = %.12lf -> %.12lf\n", i, a, next_a);
20 a = next_a;
21 }
22 return 0;
23}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected