problem with psi digamma function
3 ビュー (過去 30 日間)
古いコメントを表示
Can anyone help? I try to use the psi function to evaluate a complex number. It suggests in the help that I should convert number to sym first and then evaluate. I tried the examples in the math works page: http://www.mathworks.co.uk/help/toolbox/symbolic/psi.html
This works: [psi(1/2) psi(2, 1/2) psi(1.34) psi(1, sin(pi/3))] ans =
-1.9635 -16.8288 -0.1248 2.0372
But then when I tried this:
[psi(sym(1/2)), psi(1, sym(1/2)), psi(sym(1/4))] ??? Error using ==> psi Input must be single or double.
Please any help with this?
0 件のコメント
回答 (2 件)
Walter Roberson
2012 年 2 月 2 日
Sorry, system ate my earlier response:
Your expression psi(1, sym(1/2)) has a double precision number as the first parameter, so the MATLAB psi routine is the one that is dispatched. And then that routine complains because the second parameter is not a floating point number.
Cure: psi(sym(1), sym(1/2))
Better yet: psi(sym(1), sym(1)/sym(2))
or psi(sym(1), sym('1/2'))
Remember, sym() with a numeric expression as a parameter will evaluate the numeric expression before passing it to sym. sym() on a quoted will treat the expression in the string symbolically.
2 件のコメント
Walter Roberson
2012 年 2 月 2 日
Looks like there was no direct interface to psi in R2010a; it is not in the Special Functions list http://www.mathworks.com/help/releases/R2010a/toolbox/symbolic/f3-157665.html#f3-15507
psi does exist in MuPad in R2010a and can be invoked through
feval(symengine, 'psi', sym(1/2), sym(1))
http://www.mathworks.com/help/releases/R2010a/toolbox/mupad/stdlib/psi.html
Please note that this used the arguments in the other order than the R2011 MATLAB psi() interface to the MuPAD psi() routine.
Kai Gehrs
2012 年 2 月 7 日
Hi Ali,
just for the future: you may want to have a look at
mfunlist
in the Symbolic Math Toolbox interface in MATLAB. This gives access to special functions available in MuPAD by a more convenient syntax than maybe the
evalin
command does. For example
mfun('Psi',2,4)
corresponds to
psi(2,4)
but internally calls MuPAD's implementation of the PSI function.
Hope this helps a bit and best regards,
-- Kai
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!