MATLAB Integrate y=x/(exp(x)-1) in MATLAB

  • Thread starter Thread starter leftbank007
  • Start date Start date
  • Tags Tags
    Integration Matlab
AI Thread Summary
The discussion centers on integrating the equation y=x/(exp(x)-1) from 0 to 1 using Matlab. The user initially attempts to use the built-in int function but encounters incorrect results. Suggestions include using the integral function with a lambda expression: integral(@(x)x./(exp(x)-1),0,1), and employing the trapezoidal rule for numerical integration. There is a debate about the merits of using built-in Matlab functions versus writing custom integration routines. While some argue that relying on Matlab's optimized algorithms is generally more efficient, others emphasize the educational value of developing one's own routines to understand the underlying processes better. The conversation highlights the balance between using established methods for efficiency and the importance of grasping the fundamentals through custom implementations, especially in an educational context.
leftbank007
Messages
1
Reaction score
0
Hi, I have a problem of integration in Matlab. I want to integrate the following equation:
y=x/(exp(x)-1)
and x is from 0 to 1.

I use int(y,0,1), but it seems that it does not give correct result.
Could you help me how to do it in Matlab? Thanks!
 
Physics news on Phys.org
Try constructing the sum.
 
Write your own integration routine. The use of Trapzium rule works very well in Matlab.
 
>integral(@(x)x./(exp(x)-1),0,1)

This is how you integrate in Matlab. It is ridiculous to implement your own algorithm for anything other than educational purposes.
 
It's good if the standard way is difficult implemented. I wrote all my own routines in matlab, even the Fourier transform bit.
 
Quite a lot of effort goes into refining numerical methods. The optimization of your codes are without any doubt far inferior to what is already implemented by matlab. Also being able to learn the standard way to implement is a very crucial skill itself.
 
True enough, but things like the Fourier transform, don't give the Fourier transform, they give something else, and if you have no idea what they're doing, then you might as well write your own and understand what is going on.

Don't get me wrong, there ARE a lot of routines that I trust MATLAB with without even thinking about writing myself, but some I just have no idea what is being done or the way that MATLAB implements it is impossible to code into your own routines.
 
If there is some issue, as in this case, about the built-in approaches, then writing your own adds transparency and comparing different approaches can build confidence in a student.
Note: the question above is in an educational context: it is for educational purposes that this approach has been suggested.
Anyway - it's not difficult.
 

Similar threads

Replies
2
Views
3K
Replies
8
Views
2K
Replies
2
Views
3K
Replies
32
Views
4K
Replies
4
Views
4K
Replies
4
Views
1K
Back
Top