This is totally embarrassing but I have never coded, much less programmed, anything in my life and suddenly my applied linear algebra course requires us to write a code for a project.

The project has us write a code that will calculate the value of a given definite integral. Sounds simple enough, but honestly I have no idea where to begin.

I should mention that I'm a 4th-year graduate student in mathematics taking this course to meet the higher-level course requirement for my degree. My emphasis has been in analysis so I have a pretty firm grasp on linear algebra, calculus, and real/complex analysis concepts, all of which I assume will aid in this endeavor. I completely lack the experience to code, however.

Where do I start? What language is easiest to learn; I've heard Python and R but am looking for recommendations?

Also, what is meant by "mesh size"? We are to choose our own mesh size and method of numerical integration.

Any advice is greatly appreciated, thank you!

  • 2
    $\begingroup$ Python is easier to pick up in my opinion. If you know Riemann sums, you know how to approximate an integral. $\endgroup$ – Gabriel Romon Sep 3 '19 at 17:50
  • $\begingroup$ There are some books that can help you with the development of a numerical method and the code itself: Burden, R. L. (2016). Numerical analysis (10th ed.). (J. D. Faires, & A. M. Burden, Coaut. des). Boston, MA: Cengage Learning. Chapra, S. C. (c1998). Numerical methods for engineers: with programming and software applications (3rd ed.). (R. P. Canale, Coaut. de). Boston, MA: McGraw-Hill. $\endgroup$ – Thales Sep 3 '19 at 17:51
  • $\begingroup$ Just take python if you don't want to regret in future $\endgroup$ – Harshit Gupta Sep 3 '19 at 17:51
  • 1
    $\begingroup$ "I'm a 4th year grad student" Don't worry, this will be easy for you. My recommendation: Step 1: Install the Anaconda distribution of Python. Step 2: Open the Spyder IDE (which comes with the Anaconda distribution). Step 3: At the Spyder console, type print('hello world') and hit enter. Try out a few other commands at the Spyder console. Step 4: In the Spyder text editor on the left, type print('hello world'). Run your code by clicking on the green arrow at the top of the page. To evaluate an integral numerically, chop up the interval and sum the individual contributions using for loop. $\endgroup$ – littleO Sep 3 '19 at 18:11
  • 1
    $\begingroup$ Despite the other comments, I think that PARI/GP is better for your purpose since it is closer to mathematics notation and easier to use and learn. For example, to compute the numerical value of the definite integral $\,\int_0^1 f(x)\,dx\,$ where $\,f(x)=x^2-x\,$ you can use (f(x)=x^2-x); intnum(x=0,1,f(x)). $\endgroup$ – Somos Sep 3 '19 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.