0

I need to define a function that integrates a function in some interval and returns its numerical value. I am not allowed to use built in functions for integrating in Mathematica.

This is my code that won't work: http://pokit.org/get/?93856fe8f2070ba781028f8634b9ac3a.jpg

This is a code from a friend that works: http://pokit.org/get/?d712a81fb8c3078f4d8ad60a43b7bf0e.jpg

We are both using Wolfram Mathematica 8.0. I don't know what's wrong with my code, and why I can't obtain a normal numerical result?

bonehead
  • 951

1 Answers1

1

Somewhere earlier (off screen from what you've shown) you have set $f$ equal to $x$ with a statement like:

f=x

You can tell this due to the repeating expression: $1.0001[1.0001]$, $1.0002[1.0002]$, etc where it is trying to evaluate $f[x]$.

You can fix this with:

Clear[f]
Ian Miller
  • 11,844
  • 1
    Note that even if you've deleted the line from the notebook file you're using, the definition persists in memory. If this suggestion doesn't fix things, you can also quit the kernel (under the "Evaluation" menu), which wipes everything from memory and starts fresh. – Michael Seifert Jun 11 '16 at 13:22
  • @Ahmed Definitely good advice here from Michael. The fact that you are up to input 232 suggests you've been at it a while and there is probably all sorts of persistant junk in your kernal. Quitting and starting a new kernel is good to do with a small project like this. – Ian Miller Jun 11 '16 at 13:26
  • Thank you very much! Solved it immediately. Sorry about the misplacement of the post, I'm new here so bear with me. Here's the screenshot of the functional code: http://pokit.org/get/?07a00a95621774993c3edc075b0e0f3b.jpg

    Also, thanks for the advice about kernel quitting. And if I'm not asking for too much can you give me any resources and advice (books, etc.) from where I could learn advanced computation. I yet have to discover and learn MATLAB and Fortran, and I'm a beginner in Mathematica, so I would be thankful for any direction and advice. Thanks again!

    – bonehead Jun 11 '16 at 16:51