Mathematica Trying to define a integrating function in Mathematica

AI Thread Summary
The discussion centers on a user attempting to define a function in Mathematica that integrates another function over a specified interval without using built-in integration functions. The user encountered issues with their code, which did not yield the expected numerical results. They compared their code with a friend's working version but were unable to identify the problem. The solution was eventually found by quitting the local kernel in Mathematica, which cleared any previous symbolic or functional assignments that were interfering with the integration process. The user realized that a prior definition of the function 'f' was causing conflicts, leading to incorrect evaluations in their integration attempt.
CherryWine
Messages
29
Reaction score
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?
 
Physics news on Phys.org
CherryWine said:
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?

It's solved guys. For anyone that might have the same problem here's the probable solution: go to the Evaluation tab and from there quit your local kernel. This will delete any saved symbolic or functional assignments you've given somewhere before in Mathematica.
Specifically in my problem, I defined a function f as something else somewhere before, and didn't erase the assignment, and then when I tried to run the program for integrating it gave me the trash result you can see in the screenshot. You can see that the program is repeating the part with f[x] in it in the expression, which indicates that the function f is probably assigned to something else that's blocking the correct evaluation of the program.
 

Similar threads

Back
Top