The original text: The calculation of the Hermite polynomial with the recursive function
"C and Pointers" 7th Chapter 1th Programming Questions:
Hermite polynomials (Ernie polynomial) is defined in this way:
For example, the value of H3 (2) is 40. Please write a recursive function to calculate the value of HN (x). The function prototypes are:
int int int x);
1 /*2 * * Calculates the value of Hermite polynomials (Ernie-polynomial)3 */4 5#include <stdio.h>6 7 intHermiteintNintx);8 9 int Ten Main () One { A intn, x; -scanf"%d%d", &n, &x); -printf"%d", Hermite (n, x)); the return 0; - } - - /* + * * Calculates the value of the Hermite polynomial, the recursive function version - */ + int AHermiteintNintx) at { - intresult; - - if(N <=0 ) -result =1; - Else { in if(n = =1 ) -result =2*x; to Else +result =2* x * Hermite (N-1, X) --2* (N-1) * Hermite (N-2, x); the } * returnresult; $}
Using recursive function to calculate the Hermite polynomial