Python Can Python handle numeric integration with exponential functions?

AI Thread Summary
The discussion revolves around writing a Python program to numerically evaluate the function y(t) = exp(Integrate[A(x), x]) from 0 to t. The user initially attempted to use the quad function from scipy.integrate but found it inadequate for this specific form. Clarification was sought on the expression, confirming that the goal is to compute y(t) = exp(∫_0^t A(x) dx) for a specific function A(x). It was noted that while quad can evaluate integrals, it does so for one value of t at a time. A solution was proposed, demonstrating how to define a function that utilizes quad within another function to compute y(t) effectively. The example provided illustrates how to define both the integrand and the function y(t), allowing for numerical evaluation across different values of t.
sola maths
Messages
8
Reaction score
0
I'm trying to write a python program that is able to numerically execute functions of the form:

y(t) = exp(Integrate[A(x),x]) within the bounds of 0 and t

I tried using quad from scipy.integrate but it seems not to be able to evaluate expressions of this form.

Any other suggestions on appropriate packages or commands?
 
Technology news on Phys.org
sola maths said:
I'm trying to write a python program that is able to numerically execute functions of the form:

y(t) = exp(Integrate[A(x),x]) within the bounds of 0 and t

I tried using quad from scipy.integrate but it seems not to be able to evaluate expressions of this form.

Any other suggestions on appropriate packages or commands?

Can you be a bit more specific sola maths? Do you mean:

y(t) = \exp(\int_0^t A(x) \, dx)

You have some specific function A(x) that you can evaluate numerically?

Also, is that just you integrand? Do you need to evaluate,

\int_a^b \, e^{\int_0^t A(x) \, dx} \, dt
 
Hi uart,

Yes, I have some function A(x) that I need to evaluate numerically as x changes. The first expression you wrote is what I meant.
 
sola maths said:
Hi uart,

Yes, I have some function A(x) that I need to evaluate numerically as x changes. The first expression you wrote is what I meant.

Ok so it's just y(t) = \exp(\int_0^t A(x) \, dx) that you need to evaluate.

Quad can do this easily, but only for one particular value of "t" at a time. However you could call it (quad) from within a function if you wished to properly make a function of "t". For example,

Code:
def functA(x):
     return x*x/2.0

def functY(t):
     return exp(integrate.quad(functA,0,t)[0])

functY(3)
90.017131300521896
 
Your explanation makes lots of sense...

I'd defined a function but had difficulty making it a function of t... Thanks.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
I am trying to run an .ipynb file and have installed Miniconda as well as created an environment as such -conda create -n <env_name> python=3.7 ipykernel jupyter I am assuming this is successful as I can activate this environment via the anaconda prompt and following command -conda activate <env_name> Then I downloaded and installed VS code and I am trying to edit an .ipynb file. I want to select a kernel, via VS Code but when I press the button on the upper right corner I am greeted...

Similar threads

Replies
1
Views
1K
Replies
4
Views
5K
Replies
16
Views
2K
Replies
6
Views
7K
Replies
3
Views
2K
Replies
3
Views
4K
Replies
6
Views
3K
Replies
7
Views
5K
Back
Top