有人可以向我解釋我將如何使用割線方法找到方程的根? 該方程是:(v/b) ^2sin(alpha)= kr * Ts^4 +Uc *Ts -q
我必須找到Ts
。我有所有其他信息,但是我對使用seccant方法應該做的事感到困惑。任何幫助將不勝感激。幫助割線尋根C++
這裏是我到目前爲止的代碼:
#include <iostream>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
void secant(double, double, double, double, double, double, double);
int main()
{
double kr, uc, q, b, radians;
const double PI = 4.0 * atan(1.0);
ifstream datain("shuttle.txt");
ofstream dataout("results.txt");
datain >> kr >> uc >> q >> b;
int velocity = 16000;
double angle = 10;
for (int velocity = 16000; velocity <= 17500; velocity += 500) {
for (int angle = 10; angle <= 70; angle += 15) {
radians = angle * PI/180;
cout << velocity << endl;
cout << radians << endl;
cout << angle << endl;
secant(angle, radians, velocity, kr, uc, q, b);
}
}
getchar();
}
void secant(double angle, double radians, double velocity, double kr, double uc,
double q, double b)
{
}
你能在紙上找出一個例子嗎?首先嚐試一下。提示:首先,重新排列方程,使得你在一側得到'Ts',而在另一側得到'Ts'。如果你不能做代數,你不能做這種編程難題...... – 2011-05-10 04:49:09