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

  • Context: MATLAB 
  • Thread starter Thread starter leftbank007
  • Start date Start date
  • Tags Tags
    Integration Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
7 replies · 2K views
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
>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.