[問題] 函式的表示方式
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Dev c++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
有一數值分析題目的範例 使用的程式碼 其中一段為
/* Change function F for a new problem */
double F(double X)
{
double f;
f = exp(2*X)*sin(3*X);
return f;
}
現在題目只將方程式更改為 f = (X^2)*ln((X^2)+1)
於是我將程式碼中函數值改為 f = (X^2)*log((X^2)+1) 這樣會執行失敗
但如果我將方程式列為 f = X*log(X+1)則能正常執行
於是我想問是不是次方還需要更改別的程式碼
不好意思 我是個完全初學的人...
附上程式碼 http://codepad.org/G6zZaqwv
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
48 invalid operands of types `double' and `int' to binary `operator^'
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/G6zZaqwv
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.169.157.33
→
11/20 19:33, , 1F
11/20 19:33, 1F
→
11/20 19:34, , 2F
11/20 19:34, 2F
→
11/20 19:36, , 3F
11/20 19:36, 3F
→
11/20 19:45, , 4F
11/20 19:45, 4F
→
11/20 19:56, , 5F
11/20 19:56, 5F
→
11/20 20:05, , 6F
11/20 20:05, 6F
→
11/20 20:13, , 7F
11/20 20:13, 7F
→
11/20 20:22, , 8F
11/20 20:22, 8F
→
11/20 21:03, , 9F
11/20 21:03, 9F
推
11/20 21:14, , 10F
11/20 21:14, 10F
→
11/20 21:15, , 11F
11/20 21:15, 11F
→
11/20 21:16, , 12F
11/20 21:16, 12F
→
11/20 21:17, , 13F
11/20 21:17, 13F
→
11/20 22:06, , 14F
11/20 22:06, 14F
→
11/20 22:48, , 15F
11/20 22:48, 15F
→
11/20 22:48, , 16F
11/20 22:48, 16F
→
11/20 22:49, , 17F
11/20 22:49, 17F
→
11/20 22:49, , 18F
11/20 22:49, 18F
→
11/20 22:50, , 19F
11/20 22:50, 19F
→
11/21 00:38, , 20F
11/21 00:38, 20F
→
11/21 00:38, , 21F
11/21 00:38, 21F
→
11/22 17:34, , 22F
11/22 17:34, 22F