Answer the question
In order to leave comments, you need to log in
Why do some, insignificant parentheses change the answer?
I wrote a program that was supposed to calculate the recurrent formula.
I didn't get the answers. I decided to remove some brackets and everything came together.
Can you please explain how formula 1 differs from formula 2?
Why is there one answer for the first formula and another for the second?
Maybe the problem was in the priority of operations?
1)a = a * (-x)*(2*i+1)/(2*i);
2)a = a * (-x)*((2*i+1)/(2*i));
The value according to the control formula should be equal to the sum, taking into account the error.
C++ language:
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
double s,x,e,a,y;
int i = 1;
cout<<"Аргумент: "<<endl;
cin>>x;
cout<<"Погрешность: "<<endl;
cin>>e;
a = 1;
s = a;
y= 1/sqrt(pow((1+x),3));
while(e <= abs(a))
{
a = a *(-1*x)*((2*i+1)/(2*i));
s +=a;
i++;
}
cout<<"Сумма ряда"<<endl;
cout<<s<<endl;
cout<<"Контрольная формула "<<endl;
cout<<y;
return 0;
}
Answer the question
In order to leave comments, you need to log in
(-x)*(2*i+1)/(2*i)
- a real number is multiplied by an integer, the result is real, then a real number is divided by a real number, the result is real. - an integer is divided by an integer, the result is an integer , then a real number is multiplied by an integer, the result is real.
(-x)*((2*i+1)/(2*i))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question