[問題] 牛頓法出錯
下面是我寫的牛頓法:
program ENVE-MATH
implicit real*8 (a-h,o-z) !宣告
write(*,*)"此方程式為ax^4+bx^3+cx^2+dx+e"
write(*,*)"請輸入方程式的a值"
read(*,*)a
write(*,*)"請輸入方程式的b值"
read(*,*)b
write(*,*)"請輸入方程式的c值"
read(*,*)c
write(*,*)"請輸入方程式的d值"
read(*,*)d
write(*,*)"請輸入方程式的e值"
read(*,*)e
write(*,*)"你輸入的方程式為ax^4+bx^3+cx^2+dx+e"
write(*,*)"請輸入初始值"
read(*,*)x
write(*,*)"請輸入誤差值"
read(*,*)z
1 f1=a*x**4+b*x**3+c*x**2+d*x+e !f1是原方程式
f2=4*a*x**3+3*b*x**2+2*c*x+d !f2是f1的一次微分
x2=x-(f1/f2) !算出新數值
error=abs(x2-x) !計算誤差的絕對值
if(error<=z)then
go to 2
end if
x=x2
write(*,*)x
go to 1
2 write(*,*)x2
stop
end
但是它顯示我有一個地方出錯
有高手可以給予指教嗎
感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.120.29.185
→
11/03 18:16, , 1F
11/03 18:16, 1F
推
11/03 18:22, , 2F
11/03 18:22, 2F
→
11/04 00:19, , 3F
11/04 00:19, 3F
→
11/04 00:20, , 4F
11/04 00:20, 4F
→
11/04 00:21, , 5F
11/04 00:21, 5F
→
11/04 00:22, , 6F
11/04 00:22, 6F
→
11/04 21:54, , 7F
11/04 21:54, 7F
→
11/04 21:55, , 8F
11/04 21:55, 8F
推
11/04 22:16, , 9F
11/04 22:16, 9F
→
11/04 22:18, , 10F
11/04 22:18, 10F
→
11/04 22:18, , 11F
11/04 22:18, 11F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章