Why SN function so slow?

I used Jacobi elliptic function SN in my program, it runs so slow. When I switch to a complicated approximation function to run the same program, it runs at least 50 times faster. Is it normal?

 Accepted Answer

jacobiSN is executed by the Symbolic Toolbox, using the current digits setting to control precision.
You might possibly be able to get higher performance by reducing the digits() from the default of 32 to something lower. Also, make sure that any numbers you pass in are symbolic floating point, vpa not rationals or symbolic expressions such as alpha = sym(2); sin(alpha) . The default conversion of floating point constants to symbolic numbers is to conver the floating point constants to rationals (in most cases)
sym(123.45)
ans = 
sym(123.45, 'd')
ans = 
123.4500000000000028421709430404
sym("123.45")
ans = 
123.45

More Answers (0)

Community Treasure Hunt

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

Start Hunting!