Finding roots on an equation

Hello, this is the first time that I program with C++. I want create a program to able to compute the root of an equation with unknown degree. I want to use "boost" library but I don't understand which is the best function to use and how to use it.

I am using Visual c++ express.

I hope you understand me and my english!!

Thanks
You have to start by writing out the steps that need to be followed exactly to solve such an equation.
If the degree of equation is equal to 2 or 3 the formula for solve this is known but if the degree of equation is > or = to 4 i have problems. I want create a general function.

I saw that in boost library (boost::math::tool) there are some function (i.e. bisect) for solve this problem but i don't understand how i can use this.

Thanks
Try these steps
Suppose Y = F(x) is your equation
1) Get the X values and corresponding Y values in two different arrays.
2) Find the derrivative of Y ( w.r.t X) i.e dY/dX
3) Scan the resultant for 0 values. Root => dY=dX is 0.
Try this link...
http://www.boost.org/doc/libs/1_37_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/roots.html
I don't know the bisect function, but I would assume it goes something like this.

This only applies to real roots, not complex ones.

Let a<b. By the intermediate value theorem, a continuous function that satisfies f(a)<0<f(b) or f(a)>0>f(b) must have a root between a and b. Let c = (b-a)/2 and consider the two regions [a,c] and [c,b]. One of these regions must contain the root in [a,b]. Reapply the theorem until b-a is within your desired accuracy.
Last edited on
Topic archived. No new replies allowed.