I'm trying to write a Python code (based on a Mathematica notebook) that includes some integrations, but I had no luck so far.
The integral I'm trying to evaluate is:
where,
*It's for Bjorken-Mtingwa Intra-beam scattering calculations.
In Python,…
First time trying out the Deriv package. I was trying to compute a very simple integral of partial derivative as a start:
Here's my attempt:
junk <- function (m) {
-m*eval(deriv(~((exp(0.1*(100-94.5)^2))/(exp(0.1*(100-94.5)^2)+exp(0.1*…
I need to numerically integrate the following:
I tried to use cubature and pracma but they don't seem to support functional integration limits. I found a attempt to use cubature by:
library(cubature)
integrand <- function(arg) {
x <- arg[1]
…
Base R provides a function D() that outputs the expression of the derivative of a given function.
For example:
f <- expression(x^3+2*x)
D(f, "x") # with respect to x
# 3 * x^2 + 2
Is there a similar function that would yield the expression of the…
How can I approximate the integral of [x^4 * sin(x)]/ [exp(1)^(x/5)] (0 to +Inf) with Monte Carlo method in R?
What I tried to do is
set.seed(666)
func1 <- function(x)
{
(x^4 * sin(x))/exp(1)^(x/5)
}
n <- 1000000
x <- rexp(n, 0.2)
f…
I know how to use the Monte-Carlo to calculate integrals, but I was wondering if it is possible to use the trapezium rule combined with numpy for efficiency to get the same integral, I am not sure which one is the fastest or is the latter…
I am using the Gauss-Laguerre quadrature to approximate the following integral
I wrote the function in R
int.gl<-function(x)
{
x^(-0.2)/(x+100)*exp(-100/x)
}
First, I used integrate() function to get the "true" value, which I double check with…
I want to solve my other question here so I need sympy to return an error whenever there is no analytical/symbolic solution for and integral.
For example if I try :
from sympy import *
init_printing(use_unicode=False, wrap_line=False,…
I've been trying to do Riemann Sums to approximate integrals in C. In my code below, I'm trying to approximate by both the trapezoidal way and the rectangular way (The trapezoidal way should be better, obviously).
I tried making an algorithm for…
I need to speed up a function. Especially the part of the integrals. Like you can see I have to integrate from 0 to Inf for different parameters every time.
I already vectorized the function. But it still runs quite slow. I already tried a parallel…
Sympy and wolframalpha have produced different result. Have done anything obviously wrong here?
import sympy as smp
smp.init_printing()
In [2]:
a,R,t = smp.symbols('a,R,t',real=True)
In [3]:
f = t**2/(1+t**2/a**2);f
Out[3]:
In…
Suppose I have measurements of two signals
V = V(t) and U = U(t)
that are periodic in time with a phase difference between them. When plotted against each other in a graph V vs U they form a Lissajous figure, and I want to calculate the area…
This is my matrix
func=structure(c(-14.7690673280818, -14.5543581356252, -12.1406211639974,
-10.7200919648493, -9.55507848352318, -9.20790894914246, -8.74647670464071,
-8.26548763467919, -7.3962484443768, -6.94590909664862, -6.63903257406218,…
How do I do a coordinate transformation (cartesian to polar) in a double integral using sympy? For example, from:
Integral(exp(-x**2-y**2), (x,-oo,oo), (y,-oo,oo))
To:
Integral(exp(-r**2)*r, (r,0,oo), (t,0,2*pi))
I need to numerically evaluate some integrals which are all of the form shown in this image:
These integrals are the matrix elements of a N x N matrix, so I need to evaluate them for all possible combinations of n and m in the range of 1 to N. The…