【发布时间】:2016-05-08 22:55:17
【问题描述】:
嗨,我有一些数据,我想把这些数据拟合成一个 polinom 首先我认为它应该是: ax^2 +bx+c 和 x+x1=-b/a ;x*x1=c/a 我写了这段代码:
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
void createfunction(double x,double x1)
{
int a,b,c;
double x2 = 1.0;
a=1;
b=(-a)*(x+x1);
c=a*(x*x1);
// int denklem=a*x2*x2+b*x2+c;
cout<<a<<"x^2+"<<b<<"x+"<<c<<endl;
// cout<<denklem;
//derive(a)
}
int main(int argc, char** argv) {
createfunction(100,101);
return 0;
}
这很奇怪,但我可以理解这种方法完全错误:(阅读这些http://mathbitsnotebook.com/Algebra1/StatisticsReg/ST2FittingFunctions.html https://en.wikipedia.org/wiki/Polynomial_regression
但我不知道如何在 c 中编写此代码 你能帮助我吗 感谢您的提前
【问题讨论】:
-
1) 这不是 C。2) 它是一个纯数学问题,而不是编程问题。
-
堆栈溢出是一个编程网站,不是针对数学问题的。这是题外话。
-
我理解你,但我想写这段代码,所以我在这里写了对不起
-
所以首先要正确计算。然后实施它。请注意,C 和 C++ 是不同的语言。
-
是的,你说得对,我很抱歉写 c
标签: function-fitting