Well, you already have it in a collection - the DataTable that you filled and used as the data source for the DataGridView - so I'd probably access the values from that.
Try this:
DataTable dt = ds.Tables[0];
double[] mathValues = new double[dt.Rows.Count];
int index = 0;
foreach (DataRow row in dt.Rows)
{
mathValues[index++] = (double) row["Math"];
}