0
$\begingroup$

I've just discovered that I can use Euler's method to estimating the slope of $y=(x + c)^2$ with perfect accuracy, regardless of what $\Delta x$ is used. What causes this?

Does it happen with other functions, what must they look like for it to happen?

I am using this method to estimate the slope, $m$ $$m \approx \frac{(x+\Delta x +c)^2-(x-\Delta x + c)^2}{2\Delta x}$$

Doesn't matter what $\Delta x$ is, the slope is always correct ...I would expect this only to work for tiny $\Delta x$, but works with large ones too.

$\endgroup$
2
  • 2
    $\begingroup$ Just expand everything and after simple computations you'll receive exact answer since $\Delta x$ cancels. $\endgroup$
    – pw1822
    Apr 20, 2020 at 1:37
  • $\begingroup$ @pw1822 If you aren't already in the process of doing so, you should write & post an answer based on your comment. $\endgroup$ Apr 20, 2020 at 1:39

2 Answers 2

1
$\begingroup$

In the quadratic function $y =x^2$, you can very easily show that the secant line between points $(a, a^2)$ and $(b, b^2)$ where $b\neq a$ is parallel to the tangent at the midpoint $(\frac 12(a+b), \frac 14(a+b)^2)$.

The slope of the secant is $\frac{b^2 - a^2}{b-a} =b+a$. Slope of the tangent at the midpoint (by calculus) is $(2)(\frac 12(a+b)) = a+b$, so they're equal and the secant is parallel to the tangent.

That's the reason for your observation. Adding a constant, or using a constant multiplier, etc. won't change the result so it applies for any function of the form $y = k(x+c)^2 + m$.

$\endgroup$
1
$\begingroup$

Let's assume $c=0$ (other cases are just a horizontal translation of this case). Then $$\frac{(x+\Delta x)^2-(x-\Delta x)^2}{2\Delta x}=\frac{4x\Delta x}{2\Delta x}=2x.$$ This is exactly the derivative of $x^2$, so this approximation is exact. This does not, of course, work for all functions $f(x)$. If in fact $$\frac{1}{2\Delta x}\left(f(x+\Delta x)-f(x-\Delta x)\right)=f'(x)$$ for all $\Delta x$, then choosing $\Delta x=x$ we see $$\frac{1}{2x}\left(f(2x)-f(0)\right)=f'(x)$$ for all $x$. You can try to solve this differential equation to find all functions $f$ for which the condition is true.


Edit: assuming analyticity, here's how you can do so. Express $f(x)$ as the power series $\sum_{n\geq0}a_nx^n$. The left hand side of the equation is the same as $$\frac{1}{2x}(f(2x)-f(0))=\sum_{n\geq0}2^na_{n+1}x^n$$ whereas the right hand side is $$f'(x)=\sum_{n\geq0}(n+1)a_{n+1}x^n.$$ Matching coefficients, we must have for each $n$ that $2^na_{n+1}=(n+1)a_{n+1}$, so either $a_{n+1}=0$ or $n+1=2^n$, in which case $n=0,1$. We therefore deduce that only coefficients that can be nonzero are $a_0,a_1$ and $a_2$, and so $f(x)$ is quadratic.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .