chore(i8n,learn): processed translations

This commit is contained in:
Crowdin Bot
2021-02-06 04:42:36 +00:00
committed by Mrugesh Mohapatra
parent 15047f2d90
commit e5c44a3ae5
3274 changed files with 172122 additions and 14164 deletions

View File

@ -1,42 +1,125 @@
---
id: 59880443fb36441083c6c20e
title: 欧拉方法
title: Euler method
challengeType: 5
videoUrl: ''
forumTopicId: 302258
dashedName: euler-method
---
# --description--
<p>欧拉方法在数值上近似具有给定初始值的一阶常微分方程ODE的解。它是解决初始值问题IVP的一种显式方法<a href='https://en.wikipedia.org/wiki/Euler method' title='wp欧拉方法'>维基百科页面中所述</a></p><p> ODE必须以下列形式提供 </p><p> :: <big>$ \ frac {dyt} {dt} = ftyt$</big> </p><p>具有初始值</p><p> :: <big>$ yt_0= y_0 $</big> </p><p>为了得到数值解我们用有限差分近似替换LHS上的导数 </p><p> :: <big>$ \ frac {dyt} {dt} \ approx \ frac {yt + h-yt} {h} $</big> </p><p>然后解决$ yt + h$ </p><p> :: <big>$ yt + h\ about yt+ h \\ frac {dyt} {dt} $</big> </p><p>这是一样的</p><p> :: <big>$ yt + h\ about yt+ h \ftyt$</big> </p><p>然后迭代解决方案规则是: </p><p> :: <big>$ y_ {n + 1} = y_n + h \ft_ny_n$</big> </p><p>其中<big>$ h $</big>是步长,是解决方案准确性最相关的参数。较小的步长会提高精度,但也会增加计算成本,因此必须根据手头的问题手工挑选。 </p><p>示例:牛顿冷却法</p><p> Newton的冷却定律描述了在温度<big>$ T_R $</big>的环境中初始温度<big>$ Tt_0= T_0 $</big>的对象如何冷却: </p><p> :: <big>$ \ frac {dTt} {dt} = -k \\ Delta T $</big> </p><p>要么</p><p> :: <big>$ \ frac {dTt} {dt} = -k \Tt - T_R$</big> </p><p>它表示物体的冷却速率<big>$ \ frac {dTt} {dt} $</big>与周围环境的当前温差<big>$ \ Delta T =Tt - T_R$成正比</big></p><p>我们将与数值近似进行比较的解析解是</p><p> :: <big>$ Tt= T_R +T_0 - T_R\; Ë^ { -克拉} $</big> </p>任务: <p>实现欧拉方法的一个例程,然后用它来解决牛顿冷却定律的给定例子,它有三种不同的步长: </p><p> :: * 2秒</p><p> :: * 5秒和</p><p> :: * 10秒</p><p>并与分析解决方案进行比较。 </p>初始值: <p> :: *初始温度<big>$ T_0 $</big>应为100°C </p><p> :: *室温<big>$ T_R $</big>应为20°C </p><p> :: *冷却常数<big>$ k $</big>应为0.07 </p><p> :: *计算的时间间隔应为0s──►100s </p>
Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value. It is an explicit method for solving initial value problems (IVPs), as described in [the wikipedia page](https://en.wikipedia.org/wiki/Euler method "wp: Euler method").
The ODE has to be provided in the following form:
<ul style='list-style: none;'>
<li><big>$\frac{dy(t)}{dt} = f(t,y(t))$</big></li>
</ul>
with an initial value
<ul style='list-style: none;'>
<li><big>$y(t_0) = y_0$</big></li>
</ul>
To get a numeric solution, we replace the derivative on the LHS with a finite difference approximation:
<ul style='list-style: none;'>
<li><big>$\frac{dy(t)}{dt} \approx \frac{y(t+h)-y(t)}{h}$</big></li>
</ul>
then solve for $y(t+h)$:
<ul style='list-style: none;'>
<li><big>$y(t+h) \approx y(t) + h \, \frac{dy(t)}{dt}$</big></li>
</ul>
which is the same as
<ul style='list-style: none;'>
<li><big>$y(t+h) \approx y(t) + h \, f(t,y(t))$</big></li>
</ul>
The iterative solution rule is then:
<ul style='list-style: none;'>
<li><big>$y_{n+1} = y_n + h \, f(t_n, y_n)$</big></li>
</ul>
where $h$ is the step size, the most relevant parameter for accuracy of the solution. A smaller step size increases accuracy but also the computation cost, so it has always has to be hand-picked according to the problem at hand.
**Example: Newton's Cooling Law**
Newton's cooling law describes how an object of initial temperature $T(t_0) = T_0$ cools down in an environment of temperature $T_R$:
<ul style='list-style: none;'>
<li><big>$\frac{dT(t)}{dt} = -k \, \Delta T$</big></li>
</ul>
or
<ul style='list-style: none;'>
<li><big>$\frac{dT(t)}{dt} = -k \, (T(t) - T_R)$</big></li>
</ul>
It says that the cooling rate $\\frac{dT(t)}{dt}$ of the object is proportional to the current temperature difference $\\Delta T = (T(t) - T_R)$ to the surrounding environment.
The analytical solution, which we will compare to the numerical approximation, is
<ul style='list-style: none;'>
<li><big>$T(t) = T_R + (T_0 - T_R) \; e^{-k t}$</big></li>
</ul>
# --instructions--
Implement a routine of Euler's method and then use it to solve the given example of Newton's cooling law for three different step sizes of:
<ul>
<li><code>2 s</code></li>
<li><code>5 s</code> and</li>
<li><code>10 s</code></li>
</ul>
and compare with the analytical solution.
**Initial values:**
<ul>
<li>initial temperature <big>$T_0$</big> shall be <code>100 °C</code></li>
<li>room temperature <big>$T_R$</big> shall be <code>20 °C</code></li>
<li>cooling constant <big>$k$</big> shall be <code>0.07</code></li>
<li>time interval to calculate shall be from <code>0 s</code> to <code>100 s</code></li>
</ul>
First parameter to the function is initial time, second parameter is initial temperature, third parameter is elapsed time and fourth parameter is step size.
# --hints--
`eulersMethod`是一个函数。
`eulersMethod` should be a function.
```js
assert(typeof eulersMethod === 'function');
```
`eulersMethod(0, 100, 100, 10)`应该返回一个数字。
`eulersMethod(0, 100, 100, 2)` should return a number.
```js
assert(typeof eulersMethod(0, 100, 100, 10) === 'number');
assert(typeof eulersMethod(0, 100, 100, 2) === 'number');
```
`eulersMethod(0, 100, 100, 10)`应返回20.0424631833732
`eulersMethod(0, 100, 100, 2)` should return 20.0424631833732.
```js
assert.equal(eulersMethod(0, 100, 100, 2), 20.0424631833732);
```
`eulersMethod(0, 100, 100, 10)`应返回20.01449963666907
`eulersMethod(0, 100, 100, 5)` should return 20.01449963666907.
```js
assert.equal(eulersMethod(0, 100, 100, 5), 20.01449963666907);
```
`eulersMethod(0, 100, 100, 10)`应返回20.000472392
`eulersMethod(0, 100, 100, 10)` should return 20.000472392.
```js
assert.equal(eulersMethod(0, 100, 100, 10), 20.000472392);