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

  • Context: MATLAB 
  • Thread starter Thread starter leftbank007
  • Start date Start date
  • Tags Tags
    Integration Matlab
Click For Summary

Discussion Overview

The discussion revolves around the integration of the function y=x/(exp(x)-1) in MATLAB, specifically over the interval from 0 to 1. Participants explore various methods for performing this integration, including built-in functions and custom routines.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant expresses difficulty in obtaining the correct result using the built-in int function in MATLAB.
  • Another suggests constructing a sum as an alternative approach to integration.
  • A different participant recommends using the Trapzium rule for numerical integration, indicating it works well in MATLAB.
  • One participant provides a specific MATLAB command, integral(@(x)x./(exp(x)-1),0,1), as a proper way to perform the integration.
  • Another participant argues that implementing custom algorithms is unnecessary unless for educational purposes, emphasizing the efficiency of built-in methods.
  • Some participants discuss the value of writing custom routines to gain a better understanding of numerical methods, particularly when standard implementations are unclear or problematic.
  • There is mention of the importance of transparency in understanding numerical methods and the potential benefits of comparing different approaches.

Areas of Agreement / Disagreement

Participants express differing views on the necessity and value of using built-in functions versus writing custom integration routines. There is no consensus on the best approach, as some advocate for built-in methods while others emphasize the educational benefits of custom implementations.

Contextual Notes

Some participants highlight that the discussion is situated within an educational context, which may influence the preference for custom routines over built-in functions.

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
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K