일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- linespectra#feurierseries#푸리에 급수
- dirichlet
- 베르누이 미분방정식
- 추정문제#normal equation#직교방정식#정사영#정사영행렬#정사영 변환
- 상태천이행렬#적분인자법#미정계수법#케일리-헤밀톤 정리
- weighted least-squares
- 멱급수법
- 정규직교행렬
- 변수분리#동차 미분방정식#완전 미분방정식
- 비제차#제차해#일반해#적분인자#적분인자법#homogeneous sol#nonhomogeneous sol#integrating factor
- 2계미방#모드#mod#특성방정식#characteristic eq#제차해
- 선형 상수계수 미분방정식#lccode#sinusoidal input
- 부분 분수분해
- 그람-슈미트 과정#gram-schmidt process
- 내적 공간#적분
- 직교행렬#정규직교행렬#orthonormal#reflection matrix#dcm
- 계수내림법#reduction of order#wronskian#론스키안#아벨항등식#abel's identity
- 미분방정식 #선형 미분방정식 #상미분 방정식
- 선형변환#contraction#expansions#shears#projections#reflection
- 푸리에 정리
- 가중 최소제곱법
- 푸리에 급수
- 여인자
- 최소자승#least-square#목적함수#양한정#정점조건#최소조건
- reflection matrix
- 선형독립#기저벡터#선형확장#span#basis
- 선형시스템연산자#라이프니츠 법칙#fundamental theorem of algebra#erf
- 여인수 행렬
- 오일러-코시 미방#계수내림법
- 내적#duality#쌍대성#dot product
OnlyOne
Numerical Solution Error and Taylor Series 본문
Numerical Solution Error and Taylor Series
Taesan Kim 2024. 9. 5. 19:30Numerical Solution Error and Taylor Series
Intro
Numerical method is processed in a digital system such as PC or MCU. The main problem of numerical method is that it can produce errors due to limited number of digits representing numbers, chopping, round-off, and truncation errors. We will analyze the total error of the numerical solution.
Representation of Error
Absolute total error:
Absolute Error = |True Value - Numerical Solution|
We need to be careful how to interpret the absolute error. For example, assume that we have obtained the solution with the true error of 1mm. Can we say this is an accurate solution? -> Compare the absolute error of '1mm' from measuring a length of 10mm vs 1000mm
Relative total error
This is non-dimensional and scale-independent.
In general, the true value is not known when solving numerical problems. Others means are used to evaluate the error or the accuracy, such as estimating the error bounds and approximating order of magnitude of errors.
Accuracy vs Precision
Accuracy: How close is the data to the target value?
Precision: Density of data
Total Numerical Error
Total error = Truncation error + Round-off error
The total error of the numerical solution is a combination of various errors.
Round-off error
The round-off error is caused by the limitation of bit count. The limitation of bit count causes underflow(the smallest number closest to zero cannot defined.), overflow, chopping(truncating repeating decimals), and rounding
Truncation error
It occurs when numerical method use approximate mathematical procedure.
For example, Taylor series.
2024.08.02 - [Mathematics/Calculus] - 테일러 급수와 테일러 정리(Taylor Series)
테일러 급수와 테일러 정리(Taylor Series)
테일러 급수와 테일러 정리(Taylor Series) 테일러 급수란, 한 점 C부근에서 f(x)와 비슷한 함숫값을 구하기 위한 무한 차수 근사식과 같다. Q. 우리는 e^(0.1)값을 어떻게 계산할 수 있을까? Q
taesan5435.tistory.com
Taylor Series practice
Header file
/*
====================================================
Handong Global University
----------------------------------------------------
Name: Taesan Kim
ID: 22300203
Create: 2024.09.05
Modifier: 2024.09.05
----------------------------------------------------
Approximation of sinusoidal and exponential function
====================================================
*/
#pragma once
#ifndef _MY_NP_H
#define _MY_NP_H
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
extern void printVec(double* vec, int row);
#define PI 3.14159265358979323846264338327950288419716939937510582
//x factorial
double factorial(int _x);
//approximation of sin in rad
double sinTaylor(double _x);
//approximation of sin in deg
double sindTaylor(double _x);
//approximation of cos in rad
double cosTaylor(double _x);
//approximation of exp in rad
double expTaylor(double _x);
// degree to radian
double deg2rad(double _x);
//power x^N
double power(double _x, int N);
#endif
Source file
#include "myNP_tutorial.h"
void printVec(double* vec, int size)
{
for (int i = 0; i < size; i++)
printf("Vector[%d] = %.1f \n", i, vec[i]);
printf("\n");
}
// factorial function
double factorial(int N)
{
int y = 1;
for (int k = 2; k <= N; k++)
y = y * k;
return y;
}
// Taylor series approximation for sin(x) (input unit: [rad])
double sinTaylor(double _x)
{
int N_max = 10;
double S_N = 0;
for (int k = 0; k < N_max; k++)
S_N = S_N + pow(-1, k) * pow(_x, 2 * k + 1) / factorial(2 * k + 1);
// [TODO] add your algorithm here
return S_N;
}
// Taylor series approximation for sin(x) (input unit: [deg])
double sindTaylor(double _x)
{
_x = PI * _x / 180;
int N_max = 10;
double S_N = 0;
for (int k = 0; k < N_max; k++)
S_N = S_N + pow(-1, k) * pow(_x, 2 * k + 1) / factorial(2 * k + 1);
// [TODO] add your algorithm here
return S_N;
// [TODO] add your algorithm here
}
double cosTaylor(double _x)
{
int N_max = 10;
double S_N = 0;
for (int k = 0; k < N_max; k++)
S_N = S_N + pow(-1, k) * pow(_x, 2 * k) / factorial(2 * k);
// [TODO] add your algorithm here
return S_N;
}
double expTaylor(double _x)
{
int N_max = 10;
double S_N = 0;
for (int k = 0; k < N_max; k++)
S_N = S_N + pow(_x, k) / factorial(k);
// [TODO] add your algorithm here
return S_N;
}
// power fuction
double power(double _x, int N)
{
double temp = _x;
for (int i = 0; i < N; i++)
{
_x = _x * temp;
}
return _x;
// [TODO] add your algorithm here
}
double deg2rad(double _x)
{
return _x * PI / 180;
}
Main file
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950288419716939937510582
#include"../../include/myNP_tutorial.h"
int main(int argc, char* argv[])
{
double x = PI / 3;
double S_N = 0;
/*===== Select the function to call =====*/
S_N = sinTaylor(x);
printf("\n\n");
printf("=======================================\n");
printf(" sin( %f[rad] ) Calculation \n", x);
printf("=======================================\n");
printf(" - My result = %3.12f \n", S_N);
printf(" - Math.h result = %3.12f \n", sin(x));
printf(" - absolute err. = %3.12f \n", S_N - sin(x));
printf("=======================================\n");
S_N = sindTaylor(60);
printf("\n\n");
printf("=======================================\n");
printf(" sin( %f[deg] ) Calculation \n", x);
printf("=======================================\n");
printf(" - My result = %3.12f \n", S_N);
printf(" - Math.h result = %3.12f \n", sin(x));
printf(" - absolute err. = %3.12f \n", S_N - sin(x));
printf("=======================================\n");
S_N = cosTaylor(x);
printf("\n\n");
printf("=======================================\n");
printf(" cos( %f[deg] ) Calculation \n", x);
printf("=======================================\n");
printf(" - My result = %3.12f \n", S_N);
printf(" - Math.h result = %3.12f \n", cos(x));
printf(" - absolute err. = %3.12f \n", S_N - cos(x));
printf("=======================================\n");
S_N = expTaylor(x);
printf("\n\n");
printf("=======================================\n");
printf(" exp( %f[deg] ) Calculation \n", x);
printf("=======================================\n");
printf(" - My result = %3.12f \n", S_N);
printf(" - Math.h result = %3.12f \n", exp(x));
printf(" - absolute err. = %3.12f \n", S_N - exp(x));
printf("=======================================\n");
system("pause");
return 0;
}
'Mathematics > Numerical Method' 카테고리의 다른 글
Solving Non-Linear Equations (0) | 2024.09.11 |
---|