Trying to define a integrating function in Mathematica

In summary, the individual is having trouble obtaining a normal numerical result when trying to define a function for integrating in Mathematica. They are not allowed to use built-in functions and have provided a code that does not work, while a code from a friend does work. They both use Wolfram Mathematica 8.0. The solution to the problem is to go to the Evaluation tab and quit the local kernel, which will delete any saved assignments that may be interfering with the correct evaluation of the program.
  • #1
29
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
  • #2
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.
 

What is an integrating function in Mathematica?

An integrating function in Mathematica is a built-in function that allows you to find the integral of a given expression. It is used to calculate the area under a curve or to find the volume of a solid, among other applications.

How do I define an integrating function in Mathematica?

To define an integrating function in Mathematica, you can use the Integrate command, followed by the expression you want to integrate and the variable of integration. For example, Integrate[x^2, x] will integrate the expression x^2 with respect to x.

What is the syntax for integrating a function in Mathematica?

The syntax for integrating a function in Mathematica is Integrate[expression, variable]. You can also specify the limits of integration by adding a third argument, such as Integrate[x^2, {x, 0, 1}] to integrate x^2 from x=0 to x=1.

Can I integrate a function with multiple variables in Mathematica?

Yes, you can integrate a function with multiple variables in Mathematica by using the Integrate command and specifying all the variables of integration. For example, Integrate[x*y, {x, 0, 1}, {y, 0, 2}] will integrate x*y over the region where x ranges from 0 to 1 and y ranges from 0 to 2.

Are there any options or settings I should be aware of when using the integrate function in Mathematica?

Yes, there are several options and settings that can affect the behavior of the Integrate function in Mathematica. For example, you can specify the method of integration, the precision of the result, and whether to use numerical or symbolic methods. It is important to consult the Mathematica documentation for a full list of options and their descriptions before using the Integrate function.

Suggested for: Trying to define a integrating function in Mathematica

Replies
4
Views
288
Replies
2
Views
89
Replies
4
Views
1K
Replies
1
Views
1K
Replies
6
Views
2K
Replies
2
Views
1K
Back
Top