| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 291 人关注过本帖
标题:请大家帮忙看看我编的龙格库塔法为什么不对,结果老不正确
只看楼主 加入收藏
dengliedison
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-8-25
结帖率:0
收藏
 问题点数:0 回复次数:0 
请大家帮忙看看我编的龙格库塔法为什么不对,结果老不正确
Public Class Form1
    Public K1 As Double, K2 As Double, K3 As Double, K4 As Double
    Public h As Double, n As Integer, a As Double, b As Double
    Public xk(1000) As Double, yk(1000) As Double, x0 As Double, y0 As Double
    Public result As Double
    Public Function f(ByVal x As Double, ByVal y As Double) As Double
        Dim res As Double
        res = y - 2.0 * x / y
        Return res
    End Function
    Public Function COMpute() As Double
        Dim i As Integer
        xk(0) = x0 : yk(0) = y0
        For i = 0 To n
            xk(i + 1) = xk(i) + h
            K1 = h * f(xk(i), yk(i))
            K2 = h * f(xk(i) + 0.5 * h, yk(i) + 0.5 * K1)
            K3 = h * f(xk(i) + 0.5 * h, yk(i) + 0.5 * K2)
            K4 = h * f(xk(i) + h, yk(i) + K3)
            yk(i + 1) = yk(i) + (K1 + 2 * K2 + 2 * K3 + K4) / 6
        Next
        Return yk(i)
    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
        a = Val(txta.Text) : b = Val(txtb.Text) : h = Val(txth.Text)
        n = (b - a) / h
        x0 = Val(txtx0.Text) : y0 = Val(txty0.Text)
        result = COMpute()
        txtResult.Text = result
    End Sub
End Class
这个是代码,图形界面是看附件,版主,帮帮忙啊,您最厉害了
搜索更多相关主题的帖子: 1000 result 
2012-04-17 10:11
快速回复:请大家帮忙看看我编的龙格库塔法为什么不对,结果老不正确
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039601 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved