Trying to define a integrating function in Mathematica

Click For Summary
SUMMARY

The discussion centers on defining a custom integration function in Wolfram Mathematica 8.0 without using built-in integration functions. The user encountered issues with their code, which produced incorrect numerical results due to a prior assignment of the function variable 'f'. The solution involved quitting the local kernel via the Evaluation tab to clear any conflicting assignments. This approach resolved the problem, allowing for proper numerical integration.

PREREQUISITES
  • Understanding of Wolfram Mathematica 8.0 syntax and functionality
  • Basic knowledge of numerical integration concepts
  • Familiarity with function definitions in Mathematica
  • Experience with managing kernel sessions in Mathematica
NEXT STEPS
  • Explore custom function definitions in Wolfram Mathematica
  • Learn about managing kernel sessions and their impact on variable assignments
  • Research numerical integration techniques without built-in functions
  • Investigate debugging strategies for Mathematica code
USEFUL FOR

Mathematica users, particularly those interested in custom numerical methods, programmers troubleshooting function definitions, and educators teaching numerical integration techniques.

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

  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K