# std::hermite in C++

std::hermite is based on the hermite polynomial function given by:

After solving the Hermite’s Polynomial, the results come out to be like the following table:

Value of n | Hermite(n,x) |
---|---|

0 | 1 |

1 | 2x |

2 | 4x^{2}-2 |

3 | 8x^{3}-12x |

4 | 16x^{4}-48x^{2}+12 |

… | … |

Examples:

Input: n = 2 x = 7

Output: 194

Formula for n = 2,

4x7x7 – 2 = 196 – 2 = 194

Input: n = 4 x = 12

Output: 324876

Formula for n = 4,

16x12x12x12x12 – 48x12x12 + 12 = 324876

**Syntax:**

std::hermite( unsigned int n, data_type x )

**Parameters: **The function accepts two mandatory parameters which are described below:

**n :**Degree of Polynomial**x :**Value of x to be put in the function. The data_tpye can be float, double or long double.

**Return value:** This function returns the value which is the answer to the hermite’s polynomial.

**Note: **The std::hermite() function runs on **GCC 7.1 (C++ 17)** version.

Below programs illustrate the std::hermite() function:

**Program 1: **

`// CPP program to demonstrate the ` `// hermite() function ` `#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 ` `#include<bits/stdc++.h> ` `int` `main() ` `{ ` ` ` `// spot-checks ` ` ` `std::cout << std::hermite(3, 10) << ` `"\n"` `; ` ` ` `std::cout << std::hermite(4, 10); ` `} ` |

*chevron_right*

*filter_none*

Output:

7880 15521

**Error handling**

- If the argument is NaN, NaN is returned and domain error is not reported.
- If n is greater or equal to 128, the behavior is implementation-defined.

**Program 2: **

`// CPP program to demonstrate the ` `// hermite() function when n>128 ` `#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 ` `#include<bits/stdc++.h> ` `int` `main() ` `{ ` ` ` `std::cout << std::hermite(129, 10) << ` `"\n"` `; ` `} ` |

*chevron_right*

*filter_none*

**Output:**

-2.26912e+149

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: **DSA Self Paced**. Become industry ready at a student-friendly price.

## Recommended Posts:

- Strict Aliasing Rule in C with Examples
- Difference between cout and puts() in C++ with Examples
- Difference between forward list and list in C++
- Short-Circuiting in C++ and Linux
- Different types of range-based for loop iterators in C++
- Learn C++ Programming Step by Step - A 20 Day Curriculum!
- Difference between C and Dart
- Check if Array elements can be maximized upto M by adding all elements from another array
- Difference between Sentinel and Counter Controlled Loop in C
- Why do we need reference variables if we have pointers
- What are the differences between C and Embedded C?
- Similarities and Difference between Java and C++
- Macros and its types in C/C++
- Reversed Range-based for loop in C++ with Examples
- How to find index of a given element in a Vector in C++

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.