Friday, October 14, 2022

atan(x)

 #include <iostream>

#include <math.h>

int main()

{

    double x,y,s,a,b;

    int k; k = - 1;

    x = 0.5;

    y = atan(x);

    std::cout << "x =" << x << ", y=" << y << " ";

    b = x * x;

    s = x; a = x * x * x;

    for (int i = 3; i < 10000000; i = i + 2)

    {

        s = s + k*a/i;

        a = a * b;

        k = k * (-1);

    }

    std::cout << "s = " << s << "\n";

  }

No comments:

Post a Comment

N-point Star in Microsoft Visual Studio Console App

#include <windows.h> #include <cmath> #include <iostream> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,...