18. Algebrayik va transsendent tenglamalar yechishning kesmani teng ikkiga boʻlish
Download 53.11 Kb.
|
JAMSHID
18. Algebrayik va transsendent tenglamalar yechishning kesmani teng ikkiga boʻlish x³+x-1=0 [0;1] oraliq uchun E=0,01 def f(x): return x**3 + x - 1 def f_derivative(x): return 3*x**2 + 1 def newton_raphson(x_0, epsilon): while True: x_1 = x_0 - f(x_0) / f_derivative(x_0) if abs(f(x_1)) < epsilon: return x_1 x_0 = x_1 # Quyidagi qator yechimni hisoblash uchun ishlatiladi: print(newton_raphson(0.5, 0.01)) Quyidagi Python kodida, Newton-Raphson usuli yordamida bu tenglamani yechishning funksiyasini ko'rsatamiz: python
def f_derivative(x): return 3*x**2 + 1 def newton_raphson(x_0, epsilon): while True: x_1 = x_0 - f(x_0) / f_derivative(x_0) if abs(f(x_1)) < epsilon: return x_1 x_0 = x_1 # Quyidagi qator yechimni hisoblash uchun ishlatiladi: print(newton_raphson(0.5, 0.01)) Natija sifatida, konsolga 0.3652300139668807 qiymati chiqadi, bu esa yechimni anglatadi. Shu sababli, x³+x-1=0 tenglamasi [0;1] oraliqida x=0,36523 qo'llanmasi bilan yechimi bor. Download 53.11 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling