Oh... attachment...

On 13.04.21 19:30, Ralf Hemmecke wrote:
> Welcome Thejasvi,
> 
> I cannot probably give you full help, but I modified your .input file a bit.
> 
> Note that ++ is for docstrings in .spad files. The usual comment starts
> with --.
> 
> The first thing that I have noticed is that legendreP requires its first
> argument to be a NonNegativeInteger. Unfortunately, FriCAS does not know
> that n-1 for n: PositiveInteger would be of type NonNegativeInteger. You
> have to help FriCAS here, i.e.,
> 
> (n-1)::NonNegativeInteger
> 
> (See start of the notebook. I have defined a few macros that I usually use.)
> 
> Still there is a problem with the aromberg function, but that comes from
> the fact that its first argument must be of type F->F.
> 
> https://fricas.github.io/api/NumericalQuadrature.html#l4e756d65726963616c51756164726174757265-61726f6d62657267
> 
> You, however, give a type DoubleFloat -> Complex(DoubleFloat).
> That cannot work.
> 
> Sorry, I have no time now to analyxe further, but according to
> 
>   F: FloatingPointSystem
> 
> for NumericalQuadrature(F), it will probably not work to use
> Complex(DoubleFloat) since
> 
> (9) -> Complex(DoubleFloat) has FloatingPointSystem
> 
>    (9)  false
> 
> In other words, aromberg is not available for Complex(DF).
> 
> Sorry that I cannot be more clear.
> 
> Ralf
> 
> PS: Please subscribe to fricas-devel for further discussion.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/299b4082-0ce5-79f2-0de9-a901207d6001%40hemmecke.org.
)version
setFormat!(FormatMathJax)$JFriCASSupport
Z ==> Integer
N ==> NonNegativeInteger
P ==> PositiveInteger
DF ==> DoubleFloat
CDF ==> Complex DF
F ==> Float

-- Some of the constant values required for the rest of the functions below 
-- These correspond to the acoustics of the problem. 

freq := 50000;
k := 2*%pi/(330/freq);
ka := 5 ;
a := ka/k;
alpha := %pi/3;
R:= a/sin(alpha);
R := numeric(R)::DF;
r1 := R*cos(alpha)/cos(theta);
NN :=  3 ;--12 + 2*ka/sin(alpha)--


-- I couldn't find inbuilt spherical bessel's functions, and so had to make 
custom functions 

-- spherical bessel function-- 
sphBessel(n: P,z: DF): CDF == besselJ(n+0.5,z)*sqrt(%pi/(2*z));
-- spherical neumann function --
sphNeumann(n: P, z: DF): CDF == besselY(n+0.5,z)*sqrt(%pi/(2*z));

sphHankel2(n: Z, z: DF): CDF == sphBessel(n,z) - %i*sphNeumann(n,z);


alternate_hankels(n: P,theta: DF): CDF ==   
    r1 := R*cos(alpha)/cos(theta)
    legendreP(n::N,cos(theta))*cos(theta) + (n+1)*sphHankel2(n+1,k*r1)

alternate_legendres(n: P, theta: DF): CDF ==
    r1 := R*cos(alpha)/cos(theta)
    
n*(n+1)*sphHankel2(n,k*r1)*(legendreP((n-1)::N,cos(theta)-legendreP(n+1,cos(theta))))/(k*r1)

legendretan(m: P, theta: DF): CDF ==
    r1 := R*cos(alpha)/cos(theta)
    legendreP(m,cos(theta))*(r1^2/R^2)*tan(theta)

one_imn_term(m: P, n: P, theta: DF): CDF == 
    r1 := R*cos(alpha)/cos(theta)
    
(alternate_hankels(n,theta)+alternate_legendres(m,theta))*legendretan(m,theta)

intg_imn_m10n20(theta: DF): CDF == one_imn_term(10,20,theta)

-- Check that the output for the Imn term works

intg_imn_m10n20(0.2)

aromberg(intg_imn_m10n20,0$DF,alpha::DF,0.99::DF,(10^(-12))::DF,10::Z,50::Z,30::Z)

Reply via email to