# normal sum value and symsum value giving different result

3 vues (au cours des 30 derniers jours)
TALACHEERU VENKATA ROHITH le 10 Déc 2021
syms m;
val1 = besseli(5,6)
val2 = symsum(besseli(m,6),m,5,5);
val3 = double(val2)
val1-val3
Output:
val1 =
7.9685
val3 =
7.9685
ans =
8.8818e-16
This difference is becoming huge for very large values such as besseli(5,56), etc. Can you explain me why this difference exist?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Pavan Sahith le 13 Fév 2024
Hello Rohith,
As per my knowledge ,the reason for the difference between 'val1' and 'val3' in your MATLAB code is due to the way MATLAB handles symbolic computations using the "symsum" function.
• In the case of 'val1', you are directly evaluating the Bessel function "besseli(5,6)" numerically and storing the result as a double-precision floating-point number.
• In the case of 'val2', you are using the symsum function to symbolically compute the sum of Bessel functions. However, when you later convert it to a double with "double(val2)", MATLAB is performing a numerical approximation to evaluate the symbolic expression, and this can introduce some numerical error.
This discrepancy in the numerical approximation can lead to small differences between 'val1' and 'val3'. When dealing with symbolic computations, especially with functions that involve special functions like Bessel functions, numerical approximation errors can occur and accumulate, especially for large values.
Using vpa (Variable Precision Arithmetic) helps to achieve higher precision in symbolic computation and may reduce the discrepancy between val1 and val3.
val3 = vpa(val2);
You can refer to the following MathWorks documentation for more details
Hope that will help.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Bessel functions dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by