Курсовая работа по Вычислительной математике МТУСИ

  • View
    379

  • Download
    6

Embed Size (px)

DESCRIPTION

: Z, K(z,) K() .

Transcript

( ) 3 : 1101 .. : .. 2012.:1. 32. 43. 54. ()55. 66. 77. Z* 88. 99. Z* 1010. WINDOWS 11 11 1111. WinAPI 12 1512. 26 27 2913. 3014. 302 1) , , 1 .2) 2 MathCad. Z, K(z,) K() 0 106 . Z* K(z*,) K() 0 106 . : 1. . 2. . 1000 . 2 :1. F(Z) (A,B), Z*. (10-10 - 10-7 ) . Z.2. Z* MathCad. : . : . : , : :0 1.25*1052.5*1053.75*1055.00*1056.25*1057.50*1058.75*1051060.5 0.598 0.691 0.778 0.854 0.916 0.962 0.99 1F Z ( )0106 K Z , ( ) K3 ( )

1]2(d : 3 F(Z) (A,B), Z*. ( )( ) 4 . R2 R2 R1 C. : . , , Mathad: , :5 . . , , .. .6 . , - (A,B), . : (10-10-10-7). , . F(Z) , : , [2*10-9;4*10-9].7 Z* . Z* , . Z* . . , F(Z) , Kz(w) K(z,w) . , K(z,w) Kz(w). , K(Z1, w) Kz(w), K(Z2, w) K(Z3, w) Z2 Z3, Z1. Z = Z1= 0.00000000268244779425.8 . , - (A,B), . :(10-10-10-7). , . F(Z) , : , [10-10,10-9]9 Z* . Z* : , Z*=10-10 K(Z,w) K3(w) [0;10-6], Z1=Z*,Z2=2*10- 10,Z3=5*10- 10: , F(Z) , Kz(w) K(z,w) . , K(z,w) Kz(w). , K(Z1, w) Kz(w), K(Z2, w) K(Z3, w) Z2 Z3, Z1. Z = Z1= 10-10.10 WINDOWS. . y=x2:x 0 1 2 3 4y 0 1 4 9 16 : . . y=x2 0 1. a=0; b=1; h=0.5; E=0.0001. : , , . . y=x2 -1 1. 0. , , .11 .121314 .Kursovaya.cpp#include "stdafx.h"#include "Kursovaya.h"#define MAX_LOADSTRING 100HINSTANCE hInst;TCHAR szTitle[MAX_LOADSTRING];TCHAR szWindowClass[MAX_LOADSTRING];ATOM MyRegisterClass(HINSTANCE hInstance);BOOL InitInstance(HINSTANCE, int);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);BOOL CALLBACK integralSettings(HWND, UINT, WPARAM, LPARAM);BOOL CALLBACK optimizSettings(HWND, UINT, WPARAM, LPARAM);BOOL CALLBACK aproksimSettings(HWND, UINT, WPARAM, LPARAM);BOOL CALLBACK zadachaSettings(HWND, UINT, WPARAM, LPARAM);int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTRlpCmdLine, int nCmdShow){UNREFERENCED_PARAMETER(hPrevInstance);UNREFERENCED_PARAMETER(lpCmdLine);MSG msg;HACCEL hAccelTable;LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);LoadString(hInstance, IDC_VMKURSOVAYA, szWindowClass, MAX_LOADSTRING);MyRegisterClass(hInstance);if (!InitInstance (hInstance, nCmdShow)){return FALSE;}hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_VMKURSOVAYA));while (GetMessage(&msg, NULL, 0, 0)){if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)){TranslateMessage(&msg);DispatchMessage(&msg);}}return (int) msg.wParam;}ATOM MyRegisterClass(HINSTANCE hInstance){WNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX);15wcex.style = CS_HREDRAW | CS_VREDRAW;wcex.lpfnWndProc = WndProc;wcex.cbClsExtra = 0;wcex.cbWndExtra = 0;wcex.hInstance = hInstance;wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_VMKURSOVAYA));wcex.hCursor = LoadCursor(NULL, IDC_ARROW);wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);wcex.lpszMenuName = MAKEINTRESOURCE(IDC_VMKURSOVAYA);wcex.lpszClassName = szWindowClass;wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));return RegisterClassEx(&wcex);}BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){ HWND hWnd; hInst = hInstance; hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) {return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){int wmId, wmEvent;PAINTSTRUCT ps;HDC hdc;switch (message){case WM_COMMAND:wmId= LOWORD(wParam);wmEvent = HIWORD(wParam);switch (wmId){case IDM_ZADACHA:DialogBox(hInst, MAKEINTRESOURCE(IDD_ZADACHA), hWnd, zadachaSettings);break;case IDM_ABOUT:DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);break;case ID_ZADANIE:DialogBox(hInst, MAKEINTRESOURCE(IDD_ZADANIE), hWnd, About);break;case IDM_EXIT:DestroyWindow(hWnd);break;default:16return DefWindowProc(hWnd, message, wParam, lParam);}break;case WM_PAINT:hdc = BeginPaint(hWnd, &ps);EndPaint(hWnd, &ps);break;case WM_DESTROY:PostQuitMessage(0);break;default:return DefWindowProc(hWnd, message, wParam, lParam);}return 0;}INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){UNREFERENCED_PARAMETER(lParam);switch (message){case WM_INITDIALOG:return (INT_PTR)TRUE;case WM_COMMAND:if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){EndDialog(hDlg, LOWORD(wParam));return (INT_PTR)TRUE;}break;}return (INT_PTR)FALSE;}.cpp// long double apr(long double w){long double rez = 0;for (int i = 0; i < aproksimOut.count;i++)rez += aproksimOut.k[i] * pow(w,i);return rez;}//, long double wz(long double w, long double z){long double R2 = 1000, R1 = 1000;if (w == 0) w = 0.00000001;long double rez = sqrt(R2*R2+(w*w*z*z*R1*R1*R2*R2))/sqrt((R1*R1)+(R2*R2)+(w*w*z*z*R1*R1*R2*R2));return rez;}//, long double fw(long double w){long double R2 = 1000, R1 = 1000;long double rez = R2/(R1+R2)+R1/(R1+R2)*(sin(w*M_PI/(2*pow(10.,6))));return rez;17}// F(X) ( )long double f(long double w, long double z, int func){switch (func){case 0:{return pow(fw(w)-wz(w,z),2);break;}case 1:{return pow(apr(w)-wz(w,z),2);break;}case 2:{return pow(w,2);break;}};return 0;} .cpplong double trapeze(long double a, long double b, long double e, long double z, int func){integralOut.count = 0;long int n = 1;long double h = b-a;long double s = (f(a,z,func)-f(b,z,func))*h/2, s1;do{s1 = s;n *=2;h = (b-a)/n;s = f(a,z,func)+f(b,z,func);for (int i = 1; i < n;i++)s+=2*f(a+i*h,z,func);s*=h/2;integralOut.s[integralOut.count] = s;integralOut.h[integralOut.count] = h;integralOut.n[integralOut.count] = n;integralOut.count++;}while (fabs(s-s1)/3 >=e);return s;} .cpplong double goldCut(long double a,long double b,long double e, long double ei, int func, int method){optimizOut.count=0;long double ai = 0, bi = 1000000; long double k1=(3.-sqrt(5.))/2.;long double k2=(sqrt(5.)-1)/2.;long double x1=a+k1*(b-a);long double x2=a+k2*(b-a);long double F1 = fOpt(ai,bi,ei,x1,func,method), F2 = fOpt(ai,bi,ei,x2,func,method);while ((b-a)>e)18{if (F1