@@ -164,12 +164,12 @@ end
164164# ODE gives the first order ODE a special function op satisfies,
165165# RHS is the right hand side
166166# growth says what to use to choose a good point to impose an initial condition
167- for (op, ODE, RHS, growth) in (
168- (:(exp), " D-f'" , " 0" , :(real)),
167+ for (op, ODE, RHS, growth) in ((:(exp), " D-f'" , " 0" , :(real)),
169168 (:(asinh), " sqrt(f^2+1)*D" , " f'" , :(real)),
170169 (:(acosh), " sqrt(f^2-1)*D" , " f'" , :(real)),
171170 (:(atanh), " (1-f^2)*D" , " f'" , :(real)),
172- )
171+ (:(erfcx), " D-2f*f'" , " -2f'/sqrt(π)" , :(real)),
172+ (:(dawson), " D+2f*f'" , " f'" , :(real)))
173173 L,R = Meta. parse (ODE), Meta. parse (RHS)
174174 @eval begin
175175 # depice before doing op
@@ -208,12 +208,16 @@ function specialfunctionnormalizationpoint2(op, growth, f, T = cfstype(f))
208208 xmin, xmax, opfxmin, opfxmax, opmax
209209end
210210
211- for (op,ODE,RHS,growth) in (
211+ for (op,ODE,RHS,growth) in ((:(erf)," f'*D^2+(2f*f'^2-f'')*D" ," 0" ,:(imag)),
212+ (:(erfi)," f'*D^2-(2f*f'^2+f'')*D" ," 0" ,:(real)),
212213 (:(sin)," f'*D^2-f''*D+f'^3" ," 0" ,:(imag)),
213214 (:(cos)," f'*D^2-f''*D+f'^3" ," 0" ,:(imag)),
214215 (:(sinh)," f'*D^2-f''*D-f'^3" ," 0" ,:(real)),
215216 (:(cosh)," f'*D^2-f''*D-f'^3" ," 0" ,:(real)),
216- )
217+ (:(airyai)," f'*D^2-f''*D-f*f'^3" ," 0" ,:(imag)),
218+ (:(airybi)," f'*D^2-f''*D-f*f'^3" ," 0" ,:(imag)),
219+ (:(airyaiprime)," f'*D^2-f''*D-f*f'^3" ," airyai(f)*f'^3" ,:(imag)),
220+ (:(airybiprime)," f'*D^2-f''*D-f*f'^3" ," airybi(f)*f'^3" ,:(imag)))
217221 L,R = Meta. parse (ODE),Meta. parse (RHS)
218222 @eval begin
219223 function $op (fin:: Fun )
@@ -230,6 +234,8 @@ for (op,ODE,RHS,growth) in (
230234 end
231235end
232236
237+ erfc (f:: Fun ) = 1 - erf (f)
238+
233239
234240exp2 (f:: Fun ) = exp (log (2 )* f)
235241exp10 (f:: Fun ) = exp (log (10 )* f)
271277sinpi (f:: Fun ) = sin (π* f)
272278cospi (f:: Fun ) = cos (π* f)
273279
280+ function airy (k:: Number ,f:: Fun )
281+ if k == 0
282+ airyai (f)
283+ elseif k == 1
284+ airyaiprime (f)
285+ elseif k == 2
286+ airybi (f)
287+ elseif k == 3
288+ airybiprime (f)
289+ else
290+ error (" invalid argument" )
291+ end
292+ end
293+
294+ besselh (ν,k:: Integer ,f:: Fun ) = k == 1 ? hankelh1 (ν,f) : k == 2 ? hankelh2 (ν,f) : throw (Base. Math. AmosException (1 ))
295+
296+ for jy in (:j , :y )
297+ bjy = Symbol (:bessel , jy)
298+ for ν in (0 ,1 )
299+ bjynu = Symbol (bjy, ν)
300+ @eval SpecialFunctions.$ bjynu (f:: Fun ) = $ bjy ($ ν,f)
301+ end
302+ end
303+
274304# # Miscellaneous
275- for op in (:(expm1),:(log1p),:(sinc),:(cosc))
305+ for op in (:(expm1),:(log1p),:(lfact),:(sinc),:(cosc),
306+ :(erfinv),:(erfcinv),:(beta),:(lbeta),
307+ :(eta),:(zeta),:(gamma),:(lgamma),
308+ :(polygamma),:(invdigamma),:(digamma),:(trigamma))
276309 @eval begin
277310 $ op (f:: Fun ) = Fun ($ op ∘ f,domain (f))
278311 end
@@ -424,18 +457,41 @@ for (funsym, exp) in Calculus.symbolic_derivatives_1arg()
424457 funsym == :sign && continue
425458 funsym == :exp && continue
426459 funsym == :sqrt && continue
427- if isdefined (Base, funsym)
428- @eval begin
429- $ (funsym)(z:: Fun{<:ConstantSpace,<:Real} ) =
430- Fun ($ (funsym)(Number (z)),space (z))
431- $ (funsym)(z:: Fun{<:ConstantSpace,<:Complex} ) =
432- Fun ($ (funsym)(Number (z)),space (z))
433- $ (funsym)(z:: Fun{<:ConstantSpace} ) =
434- Fun ($ (funsym)(Number (z)),space (z))
460+ @eval begin
461+ $ (funsym)(z:: Fun{<:ConstantSpace,<:Real} ) =
462+ Fun ($ (funsym)(Number (z)),space (z))
463+ $ (funsym)(z:: Fun{<:ConstantSpace,<:Complex} ) =
464+ Fun ($ (funsym)(Number (z)),space (z))
465+ $ (funsym)(z:: Fun{<:ConstantSpace} ) =
466+ Fun ($ (funsym)(Number (z)),space (z))
467+ end
468+ end
469+
470+ # Other special functions
471+ for f in [:logabsgamma ]
472+ @eval function $f (z:: Fun{<:ConstantSpace, <:Real} )
473+ t = $ f (Number (z))
474+ Fun (t[1 ], space (z)), t[2 ]
475+ end
476+ end
477+ function loggamma (z:: Fun{<:ConstantSpace} )
478+ t = loggamma (Number (z))
479+ Fun (t, space (z))
480+ end
481+ for f in [:gamma , :loggamma ]
482+ @eval begin
483+ function $f (a, z:: Fun{<:ConstantSpace} )
484+ t = $ f (a, Number (z))
485+ Fun (t, space (z))
435486 end
436487 end
437488end
438489
490+ for f in [:besselj , :besselk , :besselkx , :bessely , :besseli ,
491+ :hankelh1x , :hankelh2x , :hankelh1 , :hankelh2 ]
492+ @eval $ f (nu, x:: Fun{<:ConstantSpace} ) = Fun ($ f (nu, Number (x)), space (x))
493+ end
494+
439495# Roots
440496
441497for op in (:(argmax),:(argmin))
0 commit comments