- #1
khemist
- 248
- 0
Homework Statement
I need to generate coefficients of hermite polynomials up to order k. Recursion will be used.
Homework Equations
a[n+1][k] = 2a[n][k-1] - 2na[n-1][k]
The Attempt at a Solution
Its not pretty, but here is my code.
Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <math.h>
using namespace std;
int k_order;
int NDMN;
int x=0,y=0;
int main()
{
cout << "How many polynomials would you like to generate?";
cin >> NDMN;
float NARY[2][NDMN];
while(y < (NDMN - 1))
{
while(x !=2)
{
NARY[x][y] = 0;
x++;
}
y++;
x=0;
}
y = 0;
NARY[0][0] = 1;
NARY[0][1] = 0;
NARY[1][1] = 2;
while(y < (NDMN - 1))
{
while(x < 2)
{
NARY[x][y+1] = 2 * NARY[x-1][y] - 2 * y * NARY[x][y-1];
x++;
}
y++;
x = 0;
}
y = 0;
while(y < (NDMN - 1))
{
while(x !=2)
{
cout << NARY[x][y] << " ";
x++;
}
cout<<endl;
x = 0;
y++;
}
system("pause");
return 0;
}