Решение на Python упражнения 4.3: Вычисление производных в вычислительной физике, пересмотренное и расширенное Марком НьPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Решение на Python упражнения 4.3: Вычисление производных в вычислительной физике, пересмотренное и расширенное Марком Нь

Сообщение Anonymous »


I've attempted to modify the example in 'Doing Math With Python by Amit Saha: Finding The Limit Of Functions' pp 181, 182. Paraphrasing: p. 181 "...Consider a function f(x) = 1/x, written limit of 1/x = 0 as x approaches Infinity p 182: 'from sympy import Limit, Symbol, S x = Symbol('x') Limit(1/x, x, S.Infinity) Limit(1/x, x, oo dir='-') l = Limit(1/x, x, S.Infinity) l.doit()'

but am not having much luck bridging the gap from there to Exercise 4.3: Calculating derivatives in Computational Physics From the text of Computational Physics: "...Exercise 4.3: Calculating derivatives Suppose we have a function f (x) and we want to calculate its derivative at a point x. We can do that with pencil and paper if we know the mathematical form of the function, or we can do it on the computer by making use of the definition of the derivative: df dx = lim d→0 f (x + d) − f (x) d . On the computer we can’t actually take the limit as d goes to zero, but we can get a reasonable approximation just by making d small. a) Write a program that defines a function f(x) returning the value x(x −1), then calculates the derivative of the function at the point x = 1 using the formula above with d = 10−2. Calculate the true value of the same derivative analytically and compare with the answer your program gives. The two will not agree perfectly. Why not? b) Repeat the calculation for d = 10−4, 10−6, 10−8, 10−10, 10−12, and 10−14. You should see that the accuracy of the calculation initially gets better as d gets smaller, but then gets worse again. Why is this?..."

Thanks in advance. David


Источник: https://stackoverflow.com/questions/780 ... tional-phy
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»