Add-Type -AssemblyName System.Windows.Forms.DataVisualization
# 定义画反抛物线的函数
function Plot-DoubleParabola {
param(
[double]$a,
[double]$b,
[double]$c
)
# 创建x值的数组
$xValues = -100..100
# 计算每个x值对应的y值
$yValues = foreach ($x in $xValues) {
-$a * $x * $x + $b * $x + $c
}
# 使用散点图画反抛物线
$chart = New-Object -TypeName System.Windows.Forms.DataVisualization.Charting.Chart
$chart.Titles.Add('反抛物线')
$chart.ChartAreas.Add('ChartArea1')
$chart.Series.Add('Series1')
$chart.Series['Series1'].ChartType = 'Point'
for ($i = 0; $i -lt $xValues.Count; $i++) {
$chart.Series['Series1'].Points.AddXY($xValues[$i], $yValues[$i])
}
$form = New-Object -TypeName System.Windows.Forms.Form
$form.controls.Add($chart)
$chart.Dock = [System.Windows.Forms.DockStyle]::Fill
$form.ShowDialog()
}
# 使用反抛物线的系数调用函数
Plot-DoubleParabola -a 0.01 -b 0 -c 0
la -a 0.01 -b 0 -c 0