Function that integrates another function, with units

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.
  • #1
Swamp Thing
Insights Author
970
670
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.
 
Physics news on Phys.org
  • #2
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?
 
  • #3
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:

FAQ: Function that integrates another function, with units

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.

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.

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.

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.

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.

Similar threads

Replies
13
Views
2K
Replies
1
Views
1K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
6
Views
3K
Replies
1
Views
1K
Replies
1
Views
906
Replies
5
Views
2K
Back
Top