Physics 6730 Midterm Test
submit p6730 midterm answers.txt
Please be sure you submit your final version. Replacing files is
permitted until the end of the test.
N(h) = [f(x+h) - f(x-h)]/(2h).We get these results
| h | N(h) |
|---|---|
| 0.2 | 2.113 |
| 0.1 | 2.125 |
From only these results, improve the estimate of the integral. Please
show your assumptions and your work.
ans
| xi | wi |
|---|---|
| -sqrt(3/5) | 5/9 |
| 0 | 8/9 |
| sqrt(3/5) | 5/9 |
Be careful about the range of integration.
ans
template <class T> NRVecGive an example of a declaration statement that invokes this constructor. State clearly what happens when you invoke the constructor and what values the constuctor assigns to the data members nn and v.::NRVec(int n) : nn(n), v(new T[n]) {}
dt y(T)
--------------------------------
0.50 0.60024232
0.20 0.59975295
0.10 0.59974191
0.05 0.59974124
0.02 0.59974120
0.01 0.59974120
---------------------------------
Taking the value for dt = 0.01 as the exact result, demonstrate
numerically that the errors at larger step sizes vary as expected with
dt for a "fourth order" method.
double matchf(double e, void *pass_params)
{
PieceWFParam wfp; // Parameters for integrating piece of wf
Vec_DP yac(2),ybc(2);
double return_value;
// Recast pass-through pointer. See param.h
WholeWFParam *mfp = reinterpret_cast<WholeWFParam *>(pass_params);
// Common initialization of parameters wfp
wfp.el = mfp->el;
...
}