# 物理代写|计算物理代写Computational Physics代考|PHYS601

## 物理代写|计算物理代写Computational Physics代考|Programming the Root Finder

Before launching into the code let us just remind ourselves of the nature of the problem we are trying to solve. While units like Joules, kilograms, and meters are all well and good for macroscopic objects, at the quantum level these become extremely cumbersome for quantum objects; especially when performing calculations with a computer. For example, the mass of the electron is roughly $9.1 \times 10^{-31}$ $\mathrm{kg}$ and has a charge of about $1.6 \times 10^{-19}$ coulombs; these are hard numbers that will lend themselves well to precise computations. Some advocate the use of dimensionless variables such that we set a particular coefficient to unity to remove any issues of precision. For instance, we could “choose” units that set the value of $\hbar^2 / 2 m=1$; it does not matter what those units are only that the coefficient is one. However, this requires converting the result from the “dimensionless” units back to SI units or any units of choice which has its advantages but can be non-intuitive and confusing for novice programmers. An alternative is to use explicit unit conversions before computing anything and therefore have results that are immediately identifiable in SI units. The unit conversion will be different for different problems, but the common goal is to make the coefficients have an exponent of one. Typically, we can use the natural units of the problem at hand. Case in point, if we use electron masses, Angstroms, and electron volts as our units of mass, length, and energy respectively then
$$\hbar^2=7.61996386 m_e e V A^2 .$$
To see how we arrived at this number let us start with the normal definition of $\hbar$ such that
$$\hbar=\frac{h}{2 \pi}=\frac{6.62606957 \times 10^{-34}}{2 \pi} \mathrm{Js}$$
and perform some dimensional analysis on the units.

## 物理代写|计算物理代写Computational Physics代考|The Mid-Ordinate Rule

The mid-ordinate rule computes an approximation to a definite integral, made by finding the area of a collection of rectangles whose heights are determined by the values of the function at certain discrete, evaluation points along the interval. Figure $5.1$ illustrates the mid-ordinate method. Specifically, the interval $[a, b]$ over which the function is to be integrated is divided into $N$ equal subintervals of length $h=(b-a) / N$. The height of the rectangle is then determincd to be the value of the function found at the mid-point between each subinterval hence the name. The approximation to the integral is then calculated by adding up the areas (base multiplied by height) of the $N$ rectangles, giving the formula:
$$\int_a^b f(x) d x \approx h \sum_{n=0}^{N-1} f\left(x_n\right)$$
where $x_n=a+(n+1 / 2) h$. As $N$ gets larger, this approximation gets more accurate. As $N$ approaches infinity, $h$ becomes infinitesimally small (approaches $d x$ ) and we have the definition of an integral. Why is this impossible to do with a computer?

Write a $\mathrm{C}++$ program that uses the mid-ordinate rule on a function that has an analytic solution. This is so we can confirm the accuracy of the method. The improvement in accuracy of the mid-ordinate method should be on the order of $h$, written $\mathcal{O}(h)$. In other words, if the subinterval width $h$ is halved, that is, $N$ is doubled, then the error in the numerical approximation of the integral is also halved.

## 物理代写|计算物理代写Computational Physics代考|编程根查找器

myassignments-help数学代考价格说明

1、客户需提供物理代考的网址，相关账户，以及课程名称，Textbook等相关资料~客服会根据作业数量和持续时间给您定价~使收费透明，让您清楚的知道您的钱花在什么地方。

2、数学代写一般每篇报价约为600—1000rmb，费用根据持续时间、周作业量、成绩要求有所浮动(持续时间越长约便宜、周作业量越多约贵、成绩要求越高越贵)，报价后价格觉得合适，可以先付一周的款，我们帮你试做，满意后再继续，遇到Fail全额退款。

3、myassignments-help公司所有MATH作业代写服务支持付半款，全款，周付款，周付款一方面方便大家查阅自己的分数，一方面也方便大家资金周转，注意:每周固定周一时先预付下周的定金，不付定金不予继续做。物理代写一次性付清打9.5折。

Math作业代写、数学代写常见问题

myassignments-help擅长领域包含但不是全部: