Windows表单中功能的大数字
我试图做一个函数图,它可以正常工作,但是出于某种原因显示功能时,我不知道为什么代码对我看起来不错,也许我在使用的示例中做错了什么。如果您出于某种原因想知道这3个文本框中的写入内容,那么第一个是起点,第二个是终点,最后一个是步骤。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
{
double xn = Convert.ToDouble(textBox1.Text);
double xk = Convert.ToDouble(textBox2.Text);
double xh = Convert.ToDouble(textBox3.Text);
if ((xn >= xk) || (xh > (xk - xn))) { MessageBox.Show("Данные заполнены неверно"); }
else
{
double z;
double x = xn;
while (x <= xk)
{
if (x <= 0) z = (1 + x) / Math.Pow(1 + Math.Pow(x, 2), 1 / 3);
else
if (x > 0 && x <= 1) z = -x + Math.Exp(-2 * x);
else z = Math.Pow(Math.Abs(2 - x), 1 / 3);
chart1.Series[0].Points.AddXY(x, z);
x += xh;
}
}
}
}
}
im trying to do a function graph, its working but for some reason when i display function its giving me big numbers, i dunno why code looks fine to me, maybe i did something wrong with sample that i use. If you, for some reason, want to know what writen in these 3 textbox, here - first one is starting point, second one is end point, and last one is step.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
{
double xn = Convert.ToDouble(textBox1.Text);
double xk = Convert.ToDouble(textBox2.Text);
double xh = Convert.ToDouble(textBox3.Text);
if ((xn >= xk) || (xh > (xk - xn))) { MessageBox.Show("Данные заполнены неверно"); }
else
{
double z;
double x = xn;
while (x <= xk)
{
if (x <= 0) z = (1 + x) / Math.Pow(1 + Math.Pow(x, 2), 1 / 3);
else
if (x > 0 && x <= 1) z = -x + Math.Exp(-2 * x);
else z = Math.Pow(Math.Abs(2 - x), 1 / 3);
chart1.Series[0].Points.AddXY(x, z);
x += xh;
}
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您的问题可能是在表达式中的两个整数之间的划分,
因为
并且您可能会期望
测试代码(在.net core 3)
I believe your problem might be with the division between two integers of 1 / 3 in the expression
because
and you may be expecting
Test Code (in .Net Core 3)