Reputation: 407
Part of my code:
double function (double x)
{
f = x^5-3*x^4+3*x^3-2*x^2-5;
return f;
}
Problem: I am getting following errors for this part of the code:
My Goal: I am writing a code to find the roots of the following polynomial in C++, Visual Studio 2012:
I am not sure how to solve this error since I am learning C++ and this is my first time I encountered this error. There are only two aforementioned errors; rest of my code is error-free. Your help will be much appreciated. Thank you!
Upvotes: 1
Views: 4485
Reputation: 37202
The ^
operator in C/C++ is not an exponent operator (by default) - it's a bitwise XOR operator, and doesn't work on doubles.
Instead, use the pow
function.
Upvotes: 5