integral

Fourth-order Runge–Kutta method (RK4) collapses after a few iterations

微笑、不失礼 提交于 2021-02-10 18:02:10
问题 I'm trying to solve: x' = 60*x - 0.2*x*y; y' = 0.01*x*y - 100* y; using the fourth-order Runge-Kutta algorithm. Starting points: x(0) = 8000, y(0) = 300 range: [0,15] Here's the complete function: function [xx yy time r] = rk4_m(x,y,step) A = 0; B = 15; h = step; iteration=0; t = tic; xh2 = x; yh2 = y; rr = zeros(floor(15/step)-1,1); xx = zeros(floor(15/step)-1,1); yy = zeros(floor(15/step)-1,1); AA = zeros(1, floor(15/step)-1); while( A < B) A = A+h; iteration = iteration + 1; xx(iteration)

Double integration of x*np.log(x) in Python using scipy.integrate.dblquad

余生长醉 提交于 2021-02-10 14:33:11
问题 The code below uses double integration with scipy.integrate.dblquad to calculate the differential entropy, c*np.log(c) , of a copula density function c , which has one dependence parameter, theta , usually positive. Formula can be found here. import numpy as np from scipy import integrate def copula_entropy(theta): c = lambda v, u: ((1+theta)*(u*v)**(-1-theta)) * (u**(-theta) + v**(-theta) -1)**(-1/theta-2) return -integrate.dblquad(c*np.log(c), 0, 1, lambda u: 0, lambda u: 1)[0] Calling the

How to change support of multivariate integral to [0,1]^k using scipy.integrate.quad?

∥☆過路亽.° 提交于 2021-01-29 05:21:08
问题 The following k-dimension integral has dependent limits (a support dependent on gamma ): from scipy.integrate import nquad import numpy as np def func(*args): gamma = args[-1] var = np.array(args[:-1]) return (1-1/(1+gamma-np.sum(var)))*np.prod(((1+var)**-2)) def range_func(*args): gamma = args[-1] return (0, gamma-sum(args[:-1])) gamma, k = 10, 2 print(nquad(func, [range_func]*k, args=(gamma,) )) The limits are defined inside the function range_func above return (0, gamma-sum(args[:-1])) How

Python -the integral from function multiplication

倾然丶 夕夏残阳落幕 提交于 2021-01-01 06:32:18
问题 In python, I have two functions f1(x) and f2(x) returning a number. I would like to calculate a definite integral after their multiplication, i.e., something like: scipy.integrate.quad(f1*f2, 0, 1) What is the best way to do it? Is it even possible in python? 回答1: I found out just a second ago, that I can use lambda :) scipy.integrate.quad(lambda x: f1(x)*f2(x), 0, 1) Anyway, I'm leaving it here. Maybe it will help somebody out. 回答2: When I had the same problem, I used this (based on the

Python -the integral from function multiplication

无人久伴 提交于 2021-01-01 06:31:01
问题 In python, I have two functions f1(x) and f2(x) returning a number. I would like to calculate a definite integral after their multiplication, i.e., something like: scipy.integrate.quad(f1*f2, 0, 1) What is the best way to do it? Is it even possible in python? 回答1: I found out just a second ago, that I can use lambda :) scipy.integrate.quad(lambda x: f1(x)*f2(x), 0, 1) Anyway, I'm leaving it here. Maybe it will help somebody out. 回答2: When I had the same problem, I used this (based on the

Python -the integral from function multiplication

老子叫甜甜 提交于 2021-01-01 06:26:07
问题 In python, I have two functions f1(x) and f2(x) returning a number. I would like to calculate a definite integral after their multiplication, i.e., something like: scipy.integrate.quad(f1*f2, 0, 1) What is the best way to do it? Is it even possible in python? 回答1: I found out just a second ago, that I can use lambda :) scipy.integrate.quad(lambda x: f1(x)*f2(x), 0, 1) Anyway, I'm leaving it here. Maybe it will help somebody out. 回答2: When I had the same problem, I used this (based on the

How to access value of integral with JSXGraph?

懵懂的女人 提交于 2020-12-15 05:19:51
问题 I was reading: how to make a dynamic function to draw integral Graph from user input with JSXGraph? There the value of the integral is "-1.6667". How to access the value? I have tried to search help, but cannot find. 回答1: Solved: function g(x){return Math.sin(x)+1}; var F = brd.create('point', [ function(){return s.X();}, function(){return JXG.Math.Numerics.I([-2,s.X()],g);} ],{}); 来源: https://stackoverflow.com/questions/57807057/how-to-access-value-of-integral-with-jsxgraph