С++ программа для ряда тейлора
Помогите пожалуйста, новичек.
х меняется от 0 до 3 с шагом 0.5
программа должна считать у для каждого из х, но на х>1 вообще ничего не выводит и не считает. (акртангенс раскладывается в ряд тейлора)
#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<math.h>
using namespace std;
float xbeg, xend, xstep, x, y, ystand, error, t;
float param,sum,member;
void author ()
{
cout<<"Calculate this:"<<endl;
cout<<" | arctg(x)/arctg(x-5) x>1 "<<endl;
cout<<"y=| "<<endl;
cout<<" | arctg(x)+arctg(2x) 0<=x<1 "<<endl;
}
float arctan (float param, float t) //функція обчислення арктангенсу за рядом тейлора
{
float sum=param;
float member=param;
float multiplier=1;
while (fabs(member)>t) //початок циклу обчислення ряду тейлора
{ //доки не буде досягнуто точності
member*=-(param*param)/((multiplier+2)/multiplier);
sum+=member;
multiplier+=2;
}
return sum; // повернення значення суми
}
void cycle()
{
for(x=xbeg; x<=xend; x+=xstep)
{
if (x>1)
{
y=(arctan(x,t))/(arctan(x-5,t));
ystand=(atan(x))/(atan(x-5));
error=fabs(ystand-y);
printf("%f %f %f %.4f \n",x,y,ystand,error);
}
else if((x>=0)&&(x<1))
{
y=arctan(x,t) + arctan(2*x,t);
ystand=atan(x) + atan(2*x);
error=fabs(ystand-y);
printf("%f %f %f %f \n",x,y,ystand,error);
}
else printf("%f not define \n", x);
}
}
void main()
{
author ();
cout<<"Enter starting value of x,finish value and step of the cycle"<<endl;
cin>>xbeg>>xend>>xstep;
cout<<"Input error :"<<endl;
cin>>t;
cout<<" x y standart error"<<endl;
cycle();
system("pause");
}
Глобальные переменные. 3(!) функции. Нахрена это для программки в 2 десятка строк? Переделывай, потом выложи адекватный код, если проблема ещё останется