関数と導関数
2016/10/06
いつの間にか参考書変わってます(^^;)。
花火を打ち上げたときの運動だそうです。横軸は時間、縦軸は高さ。
オレンジ色の破線は導関数。
刻みが細かすぎてグラフ用紙がつぶれるので背景はコメントアウト。
'打ち上げ花火 Private Sub btnHanabi_Click(sender As Object, e As EventArgs) Handles btnHanabi.Click Dim minX As Integer = 0 Dim maxX As Integer = 5 Dim minY As Integer = -30 Dim maxY As Integer = 20 'setGrid(minX, maxX, minY, maxY) Chart1.Series.Clear() Chart1.Series.Add("ax") Chart1.Series("ax").ChartType = SeriesChartType.FastPoint Chart1.Series.Add("ax2") Chart1.Series("ax2").ChartType = SeriesChartType.FastPoint Dim y As Double Dim y2 As Double '導関数用 Dim x As Double = minX Dim s As Double = 0.1 Dim icount As Integer icount = (maxX - minX) * (1 / s) For index = 1 To icount Step s y = 20 * x - 5 * x * x ' y = 20x - 5x^2 y2 = 20 - 10 * x ' y' = 20 -10x If y > maxY Then ElseIf y < minY Then Else Chart1.Series("ax").Points.AddXY(x, y) Chart1.Series("ax2").Points.AddXY(x, y2) End If x = x + s Next End Sub