Question: You can use Linux make command to compile the program Here is all the file provide https://drive.google.com/open?id=1bFzy4p4_mpDq1xaojBbW3OXCwLSZGEPP i try to fix the polynomial.cpp like thism


You can use Linux "make" command to compile the program
Here is all the file provide
https://drive.google.com/open?id=1bFzy4p4_mpDq1xaojBbW3OXCwLSZGEPP
i try to fix the polynomial.cpp like thism but this is not working
#include "polynomial.h"
#include
#include
using namespace std;
Polynomial::Polynomial ()
{
nCoeff = 0;
coefficients = new int[nCoeff + 1];
coefficients[0] = 0;
}
Polynomial::Polynomial (int nC, int Coeffs[])
: nCoeff(nC)
{
coefficients = new int[nC];
for (int i = 0; i
coefficients[i] = Coeffs[i];
normalize();
}
Polynomial::Polynomial (const Polynomial& p):nCoeff(p.nCoeff)
{
coefficients = new int [nCoeff];
for (int i = 0; i
{
coefficients[i] = p.coefficients[i];
}
}
// destructor - releases memory for the dynamically allocated coefficient array
Polynomial::~Polynomial()
{
if( coefficients )
{
delete [] coefficients;
coefficients = NULL;
}
}
Polynomial::Polynomial (const Term& term)
{
if (term.coefficient != 0)
{
nCoeff = max(1, term.power + 1);
}
else
{
nCoeff = 1;
}
for (int i = 0; i
coefficients[i] = 0;
coefficients[nCoeff-1] = term.coefficient;
normalize();
}
void Polynomial::normalize ()
{
while (nCoeff > 1 && coefficients[nCoeff-1] == 0)
--nCoeff;
}
double Polynomial::evaluate (double x) const
{
double sum = 0.0;
int k = nCoeff;
if (coefficients)
{
for (int i = 0; i
{
--k;
sum = x * sum + coefficients[k];
}
}
return sum;
}
int Polynomial::getDegree() const
{
if (nCoeff == 1 && coefficients[0] == 0)
return -1;
else
return nCoeff-1;
}
int Polynomial::getCoeff(int power) const
{
if (power >= 0 && power
{
return coefficients[power];
}
else
{
return 0.0;
}
}
Polynomial Polynomial::operator+ (const Polynomial& p) const
{
Polynomial result;
int k = 0;
while (k
{
result.coefficients[k] = coefficients[k] + p.coefficients[k];
++k;
}
while (k
{
result.coefficients[k] = coefficients[k];
++k;
}
while (k
{
result.coefficients[k] = p.coefficients[k];
++k;
}
result.nCoeff = max(nCoeff, p.nCoeff);
result.normalize();
return result;
}
Polynomial Polynomial::operator* (int scale) const
{
Polynomial result;
for (int i = 0; i
result.coefficients[i] = scale * coefficients[i];
result.nCoeff = nCoeff;
result.normalize();
return result;
}
void Polynomial::operator*= (int scale)
{
for (int i = 0; i
coefficients[i] = scale * coefficients[i];
normalize();
}
Polynomial Polynomial::operator* (const Term& term) const
{
if (term.coefficient == 0)
return Polynomial();
Polynomial result (Term(1, getDegree() + term.power));
for (int i = 0; i
result.coefficients[i+term.power] = term.coefficient * coefficients[i];
result.normalize();
return result;
}
bool Polynomial::operator== (const Polynomial& p) const
{
if (getDegree() != p.getDegree())
return false;
for (int i = 0; i
if (coefficients[i] != p.coefficients[i])
return false;
return true;
}
std::ostream& operator
{
if (p.getDegree()
{
out
}
else
{
bool first_printed = true;
for (int i = 0; i
{
double c = p.getCoeff(i);
if (c != 0.0) {
if (!first_printed)
{
out
}
first_printed = false;
out
}
}
}
return out;
}
Polynomial approximations, if not done well, have a tendency to behave very well at the selected points but to fly off in bizarre oscillations in between those selected points. The Chebyshev polynomials are useful precisely because they don't do that. They give the smoothest possible (in a certain numerical definition of "smooth") approximation of any polynomials. The Chebyshev polynomials Pi are defined by a relationship Po(x)1; P1(x) = c * x; Pk+1(x)- 2xPk(x) Pk-I(x) Different' forms for the Chebyshev polynomials are obtaiend for different values of the constant c, the canonical choices being C = 1 For example, for c-, we have Po(x)1; Pi(x)-r; P2(x) = 2xP1(x)-P0(x) = 2x2-1 P3(x) 2xP2(x) - Pi(x) 2x(2x2 - 1)- (x) - 4x3 - 3x Pa(x) = 2xP3(x)-P2(x) = 2x(4x3-3x) _ (2x2-1) = 8x4-5x2 + 1 and so on. The program chebyshev will accept three numbers as command line parameters: 2 positive integers c and n and a floating point number x. The legal ranges for these are: 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
