Help Me plz ::non-lvalue-in-assignment problem:

Peace be upon you all.
Can any one plz help me as i am a begner to programming,
i am develping code to solve cubic equations by under given formula::

Cubic Equation solving formula:
x1 = (-Term1 + r13 * cos(q3 / 3)
x2 = (-Term1 + r13 * cos(q3 + (2 * ∏) / 3)
x3 = (-Term1 + r13 * cos(q3 + (4 * ∏) / 3)

where x1 x2and x3are the roots of the cubic equation.

where:
discriminant(Δ) = q3 + r2
q = (3c - b2) / 9
r = -27d + b(9c - 2b2)
s = r + √ (discriminant)
t = r - √ (discriminant)
term1 = √ (3.0) * ((-t + s) / 2)
r13 = 2 * √ (q[/i])

and my code is:
#include <iostream.h>
#include <math.h>
main()
{
double a=1,b=-4,c=-9,d=36;
double q=(3*(c)-pow(b,2))/9; //finding q
float n=pow(b,2); //n=for use in r,square of b
double r=(-27*(d)+b*(9*(c)-2*n)); //finding r
float o=pow(q,3); //o=qube of q,for discriminant
float p=pow(r,2); //p=square of r,for discriminant
double discriminant=o+p;
double s = r + sqrt(discriminant);
double t = r - sqrt(discriminant);
double term1 = sqrt (3.0)*((-t+s)/2);
double r13 = 2*sqrt(q);
the error occurs in below three lines:
double x1=(-term1+r13*cos(o/3));
double x2=(-term1+r13*cos(o+(2*3.145)/3));
double x3=(-term1+r13*cos(o+(4*3.145)/3));

}
please help me out:
thanx in advance..


Last edited on
Topic archived. No new replies allowed.