integral

Divergent Integral in R is solvable in Wolfram

半腔热情 提交于 2019-12-31 07:34:06
问题 I know that I asked the same question before, but as I am pretty new here the question was asked poorly and not reproducible. Therefore I try to do it better here. (If I only edit the old one probably nobody will read it) I have this double integral that I would like to integrate:Here is a picture ff<-function(g,t) exp((16)*g)*exp(-8*t-(-t-0.01458757)^2/(0.0001126501)) integrate(Vectorize(function(t) integrate(function(g) ff(g,t), -2.5,0)$value), -2, 2) Running this in R gives me the error:

Why is the eval class giving me a casting error from int to double?

牧云@^-^@ 提交于 2019-12-31 03:56:27
问题 I am trying to make a method that takes a string formula, and solves the integral of that formula by doing a Riemann's sum with very small intervals. I am using the ScriptEngine and ScriptEngineManager classes to evaluate the function (with the eval() method). For some reason, I am getting this error: Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double at sum.integral(sum.java:31) at sum.main(sum.java:13) import java.beans.Expression;

Why is my double integral is R not working

二次信任 提交于 2019-12-31 03:55:26
问题 I folloed this post here double integral in R and switched the function and limits to match below but it's not working. InnerFunc = function(x) { x + (y^2) } InnerIntegral = function(z) { sapply(y, function(z) { integrate(InnerFunc, 0, 2)$value }) } integrate(InnerIntegral, 0, 1) I get this error: Error in integrate(InnerFunc, 0, 2) : evaluation of function gave a result of wrong type 回答1: Your variables are all out of wack. This should do what you want InnerFunc <- function(x, y) { x + (y^2)

Numerical Triple Integration in R

牧云@^-^@ 提交于 2019-12-31 02:41:29
问题 Is it possible to do triple integration in R without using the cubature package? based on the answer in this post InnerFunc = function(x) { x + 0.805 } InnerIntegral = function(y) { sapply(y, function(z) { integrate(InnerFunc, 15, z)$value }) } integrate(InnerIntegral , 15, 50) 16826.4 with absolute error < 1.9e-10 For example, to code this triple integral: I tried InnerMostFunc = function(v) { v + y^2 } InnerMostIntegral = function(w) { sapply(w, function(x) { integrate(InnerMostFunc, 1, 2)

scipy.integrate.trapz and discontinuous functions

假如想象 提交于 2019-12-24 09:36:36
问题 The function scipy.integrate.trapz uses Newton-Cotes formula of order 1 as it said in the scipy documentation. However, in the derivation of this formula it is usually assumed that the integrand is a continuous function and the points, in which the value of the integrand is known, are distinct. However, I tried to approximate the integral of the function f:[0,2] --> [0,2] , defined by f(x) = 0 if x < 1 else 2 by calling scipy.integrate.trapz([0, 0, 2, 2], [0, 1, 1, 2]) and obtained the right

Standard Normal Quantile Function Integration in R

为君一笑 提交于 2019-12-24 04:25:11
问题 I need to compute a division of integrals, where the function q_alpha(z) is the quantile function of a standard normal distribution. I got a question regarding the denominator. As the normal standard distribution has Homoscedasticity, it is simmetric, continuous, etc.The integration of the denominator term its simple? I just need to elevated to the square each quantile of this function and proceed to the calculation? Right? This is my code in R: library(Bolstad) thau=1:99/100 z.standard

Are there any Haskell libraries for integrating complex functions?

帅比萌擦擦* 提交于 2019-12-24 00:58:28
问题 How to numerically integrate complex, complex-valued functions in Haskell? Are there any existing libraries for it? numeric-tools operates only on reals. I am aware that on complex plane there's only line integrals, so the interface I am interested in is something like this: i = integrate f x a b precision to calculate integral along straight line from a to b of function f on point x . i , x , a , b are all of Complex Double or better Num a => Complex a type. Please... :) 回答1: You can make

Calculate area of cross-section as function of height

喜你入骨 提交于 2019-12-24 00:37:25
问题 I'm trying to figure out how to calculate the water filled area of a river cross section for different water levels. For the cross-section I have the depth at every 25 cm over the 5 m wide river and the area can be calculated based on a nicely answered previous question Calculate area of cross section for varying height x_profile <- seq(0, 500, 25) y_profile <- c(50, 73, 64, 59, 60, 64, 82, 78, 79, 76, 72, 68, 63, 65, 62, 61, 56, 50, 44, 39, 25) library(sf) #Create matrix with coordinates m <

Simpson's method to integrate real valued functions with CUDA

和自甴很熟 提交于 2019-12-24 00:28:39
问题 I'm trying to code integration by Simpson's method in CUDA. This is the formula for Simpson's rule where x_k = a + k*h . Here's my code __device__ void initThreadBounds(int *n_start, int *n_end, int n, int totalBlocks, int blockWidth) { int threadId = blockWidth * blockIdx.x + threadIdx.x; int nextThreadId = threadId + 1; int threads = blockWidth * totalBlocks; *n_start = (threadId * n)/ threads; *n_end = (nextThreadId * n)/ threads; } __device__ float reg_func (float x) { return x; } typedef

nested trapz double integration

扶醉桌前 提交于 2019-12-23 04:21:17
问题 I'd like knowing if there is any way to bypass the call for quad2d with a nested trapz loop. I'll discuss my problem with some more detail: currently, I perform the calculation of a double integral this way: clc, clear all, close all load E_integral.mat c = 1.476; gamma = 3.0; beta_int = (c*gamma)./(k_int.*sqrt(E_integral)); figure, loglog(k_int,beta_int,'r','LineWidth',2.0), grid on; k1 = (.01:.1:100); k2 = .01:.1:100; k3 = -100:.1:100; int_k3 = zeros(size(k2)); int_k3k2 = zeros(size(k1));