C語言如何實(shí)現(xiàn)黎曼和求定積分

這篇文章主要介紹了C語言如何實(shí)現(xiàn)黎曼和求定積分,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

成都創(chuàng)新互聯(lián)是一家專業(yè)提供渝北企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站建設(shè)、做網(wǎng)站、html5、小程序制作等業(yè)務(wù)。10年已為渝北眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。

具體內(nèi)容如下

通過黎曼和解定積分既是把在xy平面中函數(shù)曲線與x軸區(qū)間區(qū)域劃分成多個(gè)矩形并求它們的面積之和,矩形數(shù)量越多,得出的面積越精確。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 
int main(){ 
 float function1(float);        //函數(shù)f(x)1
 float function2(float);        //函數(shù)f(x)2
 float function3(float);        //函數(shù)f(x)3
 void integration(float f(float),float,float);  //求定積分方法,參數(shù)為,函數(shù)fx,區(qū)間[a,b]的兩個(gè)點(diǎn) 
 
 int result_a=integration(function1,1,0);   
 int result_b=integration(function2,1,-1); 
 int result_c=integration(function3,2,0);  
}
 
void integration(float f(float),float endPos,float startPos) //求定積分方法,參數(shù)為,函數(shù)fx,區(qū)間[a,b]的兩個(gè)點(diǎn) 
{ 
 float x;
 float totalArea=0; //totalArea,所有矩形的總面積 
 float n=1000;  //將函數(shù)曲線下方劃為n個(gè)矩形,n值越大,精確值越高 
 float width;   //單個(gè)矩形寬度 
 float area=0;  //單個(gè)矩形面積 
 width=(endPos-startPos)/n;  //求單個(gè)矩形寬度,既是函數(shù)總長度除以矩形數(shù)量 
 for(float i=1;i<=n;i++)   //計(jì)算每個(gè)矩形的面積 
 {  
 x=startPos+width*i;  //轉(zhuǎn)入到xy平面, 通過i的遞增,得出每個(gè)矩形底部x的值,以求矩形高度  
 area=f(x)*width;   //用x做實(shí)參調(diào)用函數(shù)進(jìn)一步求出y值,既矩形的高度,再用底乘高得出面積  
 totalArea=totalArea+area;   //各個(gè)矩形面積相加 
 } 
 printf("the value of function is %f",t2); 
}
 
float function1(float x){ //函數(shù)f(x)1
 float y; 
 y=sin(x); 
 return y;
}
 
float function2(float x){ //函數(shù)f(x)2
 float y; 
 y=cos(x); 
 return y;
}
float function3(float x){ //函數(shù)f(x)3
 float y; 
 y=exp(x); 
 return y;
}

C語言如何實(shí)現(xiàn)黎曼和求定積分

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“C語言如何實(shí)現(xiàn)黎曼和求定積分”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!

標(biāo)題名稱:C語言如何實(shí)現(xiàn)黎曼和求定積分
當(dāng)前URL:http://muchs.cn/article8/jpgpip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航定制開發(fā)、網(wǎng)站設(shè)計(jì)、網(wǎng)站導(dǎo)航、網(wǎng)站策劃、用戶體驗(yàn)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司