[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bessel functions with octave
From: |
john |
Subject: |
bessel functions with octave |
Date: |
Wed, 17 Aug 2011 11:02:55 -0700 (PDT) |
Hi,
here are the other programs .I did little changes alo compare with
16/08/2001)
function y=besintj0(x)
%-----------------------------------------------------------------------
% Approximate the Bessel's function of the first kind of order zero
% via the following integral definition.
% J0(x) = (1/pi)*integral (from 0 to pi) of cos(x*sin(q))*dq
% Programming Note:
% For large values of x, apply the asymptotic approximation formula.
% J0(x)=sqrt(2/pi/x)*cos(x-pi/4), for x>25
% Instructor: Nam Sun Wang
%-----------------------------------------------------------------------
global x
% pi = 3.141593 already defined in Matlab
% Pass x into the integrand through "common"
% Call an integration routine to do the grunt work.
% y = 1/pi * quad8('bintegra', 0, pi); ... old
y = 1/pi * quadl(@bintegra, 0, pi);
------------------------------------------------------------------------------------------------
%-----------------------------------------------------------------------
% Approximate the Bessel function of the first kind of order 0
% via Taylor's series expansion.
% Instructor: Nam Sun Wang
%-----------------------------------------------------------------------
% Start fresh ----------------------------------------------------------
clear all
% Print out a program header -------------------------------------------
disp("Approximate the Bessel function via Taylor''s series ")
disp("expansion, which fails for x far away from the point ")
disp("of expansion around x=0. This program is accurate to ")
disp("about 5 significant figures for 0<x<10.")
disp(' ')
% Input data -----------------------------------------------------------
x = input("Enter x: ");
% Print out the results ------------------------------------------------
disp(' ')
disp(["Taylor''s series expansion gives: ", num2str(besj0(x)) ])
disp(["integral def gives: ", num2str(besintj0(x))])
disp(["Compare to Matlab''s bessel(0,x) = ", num2str(besselj(0,x))])
---------------------------------------------------------------------------------------
--
View this message in context:
http://octave.1599824.n4.nabble.com/bessel-functions-with-octave-tp3750761p3750761.html
Sent from the Octave - General mailing list archive at Nabble.com.