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.
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Translated by
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.