Skip to content

Instantly share code, notes, and snippets.

@vadimtsushko
Created October 6, 2012 10:19
Show Gist options
  • Save vadimtsushko/3844552 to your computer and use it in GitHub Desktop.
Save vadimtsushko/3844552 to your computer and use it in GitHub Desktop.
math_1.cpp
#include <iostream>
#include <math.h>
#include <conio.h>
#define E 0.0001
using namespace std;
int main ()
{
double step,x,y,sn,se,a;
double n=0;
y = 1;
a = 0;
se = 0;
sn = 0;
step = (1 - 0.1) /10;
for (x=0.1;x<1;x+=step)
{ //precision
while (abs(a)>E)
{
n++;
a = (pow(-1,n+1)*pow(x,(2*n)+1))/((4*n*n)-1);
se = se+a;
};
//n
a = 0;
for (int i = 0; i < 30; i++)
{
a = (pow(-1,n+1)*pow(x,(2*n)+1))/((4*n*n)-1);
sn = sn+a;
};
y = ((1+x*x)/2* atan(x)) - x/2;
cout << x << "\t" << se << "\t" <<sn << "\t" << y << "\n";
}
getch ();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment