習題EX4-1 利用梯行法解
n=11 a=1 b=3.2
x y
======
1.0 4.9
1.2 5.4
1.4 5.8
1.6 6.2
1.8 6.7
2.0 7.0
2.2 7.3
2.4 7.5
2.6 8.0
2.8 8.2
3.0 8.3
3.2 8.3
/* p4-1.c based on Trapezoidol Rule is
* used for computing definite integral with
* domain [a,b] with n even-grids.
*/
#include <stdio.h>
#include <math.h>
#define PI 3.141593
void main()
{
int n,i;
double a,b,x[50],y[50],tn,h ,sum=0.0;
scanf("n=%d a=%lf b=%lf",&n,&a,&b);
for(i=1;i<=n+1;i++)
scanf("%lf %lf",&x[i],&y[i]);
h=(b-a)/n;
for(i=2;i<=n;i++)
{
sum=sum+y[i];
tn=(h/2.0)*(y[1]+y[n+1]+2.0*sum);
printf("T%d=%10.6lf\n",n,tn);
}
//tn=(h/2.0)*(y[1]+y[n+1]+2.0*sum);
//printf("T%d=%10.6lf\n",n,tn);
return;
}
T11= 2.400000
T11= 3.560000
T11= 4.800000
T11= 6.140000
T11= 7.540000
T11= 9.000000
T11= 10.500000
T11= 12.100000
T11= 13.740000
T11= 15.400000
2019年1月1日 星期二
訂閱:
張貼留言 (Atom)
Node-Red 抓取 opendata 的資料集產生AQI 空氣品質指
Node-Red 抓取 opendata 的資料集產生AQI 空氣品質指標 實現透過 Node-RED 抓取環境部 OpenData(空氣品質 AQI)資料,最核心的流程為: 注入觸發(Inject) → HTTP 請求(http request) → 解析 JSON 資料(Fu...
-
數位IC設計入門-Verilog combinational logic 8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench) //數位IC設計入門-Verilog combinationa...
-
Line 發報機 Python TKinter (CONFIG_LINE Message API_2.py) import serial import serial.tools.list_ports import tkinter as tk from tkinter import...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
沒有留言:
張貼留言