It may be that I'm using MATLAB 2021a version and a fractional exact answer can not be outputted, because running your code on my end still gives the answer as a decimal approximation. I'm also not sure what even, odd functions have to do with spitting out the output.
Actually, your original answer works without using @Walter Roberson line of code, but I wanted to take the integral of the whole region instead of splitting it into half and doubling, if I have functions or areas without identical halves (odd?), I suppose there aren't exact solutions with the version I'm using.
If you have functions or areas that do not have identical halves, then it is unlikely that the function uses abs() [but possible...] int() tends to struggle a bit with abs()
Whether a function without abs() can be integrated or not... depends a lot on the function. It is easy to create functions that have no known exact integral.
if I have functions or areas without identical halves (odd?), I suppose there aren't exact solutions with the version I'm using.
Sometimes it works, sometimes not. The "abs" function is always problematic together with "int". And it doesn't have to do with your MATLAB version - it also doesn't work in R2024b as you can see above.
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
Translated by
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.