# Function that integrates another function, with units

• Mathematica
• Swamp Thing
In summary, the conversation discusses defining functions in Mathematica to calculate velocity and distance as functions of time, with units attached. The correct results with proper units are obtained when printing the values and integrals. The issue of integrating between different units is addressed and a solution is provided.
Swamp Thing
Velocity as a function of time, defined with units attached (Quantity feature of Mathematica):
Code:
fnVq[t_ ]:= 2   m/s^2   * t
fnVq[5 s]
Integrate[fnVq[tt],{tt,0 s, 2000 ms}]
10m/s
4m
When we printed above the value and integral, we got the correct results with proper units.

Now I'm trying to define another function:
Code:
fnX[tx_]:=Integrate[fnVq[tt  ], {tt ,0 ,tx   }]
fnX[6 ]
36m/(s)^2

How can I fix the above so it outputs 36 m ? Also, I would like to print say fnX[ 2000 ms ] and have it interpret the milliseconds correctly and output the correct value with correct units.

Swamp Thing said:
Velocity as a function of time, defined with units attached (Quantity feature of Mathematica):
Code:
fnVq[t_ ]:= 2   m/s^2   * t
fnVq[5 s]
Integrate[fnVq[tt],{tt,0 s, 2000 ms}]
10m/s
4m
When we printed above the value and integral, we got the correct results with proper units.

Now I'm trying to define another function:
Code:
fnX[tx_]:=Integrate[fnVq[tt  ], {tt ,0 ,tx   }]
fnX[6 ]
36m/(s)^2

How can I fix the above so it outputs 36 m ? Also, I would like to print say fnX[ 2000 ms ] and have it interpret the milliseconds correctly and output the correct value with correct units.

Observe that in the first example, you do not integrate between 0 and 2000, but between 0 s and 2000 ms. In the second example,  fnX[6] computes Integrate[fnVq[tt ], {tt ,0 ,6 }] which is not what you want; you want Integrate[fnVq[tt ], {tt ,0 s,6 s }]. Can you see how to fix the definition of fnX and what argument you must pass to it in order to get that result?

Thanks, this worked:
Code:
fnVq[t_]:=2   m/(s)^2  *t
fnX[x_]:= Integrate[fnVq[tt],{tt,0  s,x}]

fnX[6 s]
fnX[6000 ms]

Out[31] = 36 m
Out[32] = 36 m

Last edited:

## 1. What is a function that integrates another function?

A function that integrates another function is known as an integral function. It is used to find the area under a curve or the accumulation of a quantity over a given interval.

## 2. How does a function integrate another function?

A function integrates another function by finding the antiderivative of the given function. This is done by using the fundamental theorem of calculus and applying integration techniques such as substitution, integration by parts, or partial fractions.

## 3. What are the units of a function that integrates another function?

The units of a function that integrates another function will depend on the units of the given function. However, the units of the integral function will always be the product of the units of the original function and the units of the variable of integration.

## 4. What is the purpose of using a function that integrates another function?

The main purpose of using a function that integrates another function is to find the total accumulation or the net change of a quantity over a given interval. This is particularly useful in many areas of science, such as physics, engineering, and economics.

## 5. What are some real-life applications of a function that integrates another function?

Some real-life applications of a function that integrates another function include calculating the displacement of an object using its velocity function, finding the total cost of production using the marginal cost function, and determining the amount of medication in a person's body over time using the rate of change of the medication concentration.

• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
673
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• Engineering and Comp Sci Homework Help
Replies
1
Views
317
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• Topology and Analysis
Replies
2
Views
549
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K