Algorithms_in_C
1.0.0
Set of algorithms implemented in C.
|
Compute all possible approximate roots of any given polynomial using Durand Kerner algorithm More...
#include <complex.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
Macros | |
#define | ACCURACY 1e-10 |
maximum accuracy limit | |
Functions | |
long double complex | poly_function (long double *coeffs, unsigned int degree, long double complex x) |
Evaluate the value of a polynomial with given coefficients. More... | |
const char * | complex_str (long double complex x) |
create a textual form of complex number More... | |
char | check_termination (long double delta) |
check for termination condition More... | |
int | main (int argc, char **argv) |
Compute all possible approximate roots of any given polynomial using Durand Kerner algorithm
Test the algorithm online: https://gist.github.com/kvedala/27f1b0b6502af935f6917673ec43bcd7
Try the highly unstable Wilkinson's polynomial:
Sample implementation results to compute approximate roots of the equation \(x^4-1=0\):
char check_termination | ( | long double | delta | ) |
check for termination condition
[in] | delta | point at which to evaluate the polynomial |
const char* complex_str | ( | long double complex | x | ) |
int main | ( | int | argc, |
char ** | argv | ||
) |
store intermediate values to a CSV file
long double complex poly_function | ( | long double * | coeffs, |
unsigned int | degree, | ||
long double complex | x | ||
) |
Evaluate the value of a polynomial with given coefficients.
[in] | coeffs | coefficients of the polynomial |
[in] | degree | degree of polynomial |
[in] | x | point at which to evaluate the polynomial |