필터 지우기
필터 지우기

Way to handle singularity,Division by zero

조회 수: 2 (최근 30일)
Amit Kadam
Amit Kadam 2012년 12월 10일
Hi All, I am trying to find out the integral by algorithm but it is singular at right end limit.
U see beta is 0.5511 and at right hand limit 1 the term (x/((alpha*x*x)+1-alpha)).^2becomes 1 and further subtraction by 1 make it zero. I am trying (1-sqrt of eps) but I am not sure how much accurate the answer will be. With quadgk answer is 0.5.
but how sould I handle the singularity. I need an accurate answer to find value of alpha which in turn will be used to create some profiles. Thanks in advance. Amit Kadam
clc;
clear;
syms r;
Alpha =1.436269843278397;
H = 1;
R = 1;
Theta = 0;
Beta =o.5516
a = Beta;
b = 1; %(r./R);
npoints = 63;
h = (b - a) / (npoints);
node_r = sym(zeros(1,npoints));
for i=1:npoints
% The number of intervals must be even => number of points must be odd.
x = a - h + (h.*i);
if x==1
x =1-(sqrt(eps));
end
func_r= ( ( ( ( (x) ./ ( (Alpha.*(x).*(x) ) + 1 - Alpha ) ).^2 ) - 1 ) .^(- 0.5) );
node_r(i) = func_r;
end
simpson = (h / 3) .* (node_r(1) + node_r(end)) + ((4 * h) ./ 3) .* ..

답변 (1개)

Doug Hull
Doug Hull 2012년 12월 10일
Could you calculate the denominator, and if the absolute value is within a certain tolerance you branch the code to a default value for the expression?
I am surprised if in floating point you ever get zero, you might get really close.
It is not clear which denominator is going to zero.
  댓글 수: 1
Amit Kadam
Amit Kadam 2012년 12월 10일
편집: Amit Kadam 2012년 12월 10일
U see beta is 0.5511 and at right hand limit 1 the term (x/((alpha*x*x)+1-alpha)).^2becomes 1 and further subtraction by 1 make it zero. I am trying (1-sqrt of eps) but I am not sure how much accurate the answer will be with quadgk answer is 0.5.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by