Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 通过迭代开始求解的最佳方法是什么?_C++_Iteration_Equation - Fatal编程技术网

C++ 通过迭代开始求解的最佳方法是什么?

C++ 通过迭代开始求解的最佳方法是什么?,c++,iteration,equation,C++,Iteration,Equation,我正在做一个家庭项目,在那里我需要通过迭代紧密地解一个方程。 M=E-E*正弦或另一种方式E-E*正弦/M=1。 M在前面为求解,e在数据消息中给出 因此,您是否可以为E插入一个数字,并检查该值与1的接近程度,然后继续调整E的插入值,直到表达式在设定值范围内为1.00000 在软件中有没有理想的方法来解决类似的问题 我的计算函数的其余部分显示为 FP64定义为双精度 bool SV_pos_GAL_L1(int chan, FP64* x, FP64* y, FP64* z) //finds S

我正在做一个家庭项目,在那里我需要通过迭代紧密地解一个方程。 M=E-E*正弦或另一种方式E-E*正弦/M=1。 M在前面为求解,e在数据消息中给出

因此,您是否可以为E插入一个数字,并检查该值与1的接近程度,然后继续调整E的插入值,直到表达式在设定值范围内为1.00000

在软件中有没有理想的方法来解决类似的问题

我的计算函数的其余部分显示为 FP64定义为双精度

bool SV_pos_GAL_L1(int chan, FP64* x, FP64* y, FP64* z) //finds SV ECEF position in orbit at ref GAL system time
{
    FP64 smaxis = pow(GALChannel[chan].L1galData.sqrrtA, 2); //semi major axis
    FP64 nc = sqrt( MU/(pow(smaxis, 3)) ) + GALChannel[chan].L1galData.delta_n; //n corrected
    FP64 Tk = GALChannel[chan].L1galData.TOW - GALChannel[chan].L1galData.Toe;  //time since ephemeris
    FP64 M = GALChannel[chan].L1galData.M0 + nc * Tk; //mean anomaly

    FP64 E;

    FP64 v = atan( ((sqrt(1-pow(GALChannel[chan].L1galData.e,2)) * sin(E)) / (1-(GALChannel[chan].L1galData.e*cos(E))))  /  ((cos(E)-GALChannel[chan].L1galData.e) / (1-(cos(E)*GALChannel[chan].L1galData.e)))  );//true anomaly
    FP64 Omega = GALChannel[chan].L1galData.Omega0 + (Tk * (GALChannel[chan].L1galData.dot_Omega - GALChannel[chan].L1galData.w)) - ( GALChannel[chan].L1galData.w * GALChannel[chan].L1galData.Toe); //corrected longitude of ascinding node

    FP64 ArgLat = v + Omega; //argument of latitude
    FP64 Su = (GALChannel[chan].L1galData.Cus * sin(2*ArgLat)) + ( GALChannel[chan].L1galData.Cuc * cos(2*ArgLat)); //argument of latitude correction
    FP64 Sr = (GALChannel[chan].L1galData.Crs * sin(2*ArgLat)) + ( GALChannel[chan].L1galData.Crc * cos(2*ArgLat)); //radius correction
    FP64 Si = (GALChannel[chan].L1galData.Cis * sin(2*ArgLat)) + ( GALChannel[chan].L1galData.Cic * cos(2*ArgLat)); //inclination correction
    FP64 u = ArgLat + Su; //corrected arg latitude
    FP64 r = smaxis * (1 - (GALChannel[chan].L1galData.e * cos(E))) + Sr; //corrected radius
    FP64 i = GALChannel[chan].L1galData.i0 + Si + (GALChannel[chan].L1galData.dot_i * Tk); //corrected inclination
    FP64 x1 = r * cos(u);
    FP64 y1 = r * sin(u);
    x = (x1 * cos(Omega)) - (y1 * cos(i) * sin(Omega));
    y = (x1 * sin(Omega)) - (y1 * cos(i) * cos(Omega));
    z = y1 * sin(i);

    return true;
}

你听说过牛顿的方法吗?读过之后,它似乎有点耳熟能详。有限元和微积分对我来说是很多年前的事了。我可以尝试一个简单的E2=M+e*sinE1并运行它,直到E2匹配E1到很多地方。假设值收敛而不是发散