integral

R plotting integral

杀马特。学长 韩版系。学妹 提交于 2019-11-28 09:37:38
问题 I'm having some problems with integration function in R. I'm trying to plot the integral vo but it seems I'm not doing correctly. t <- seq(0, 0.04, 0.0001) vi <- function(x) {5 * sin(2 * pi * 50 * x)} vo <- function(x) {integrate(vi, lower=0, upper=x)$value} test_vect = Vectorize(vo, vectorize.args='x') plot(t, vo(t)) # should be a cosine wave plot(t, vi(t)) # sine wave vo should be a sine wave but using test_vect gives me wrong plot and using vo directly gives error 'x' and 'y' lengths

What causes this error (AttributeError: 'Mul' object has no attribute 'cos') in Python?

寵の児 提交于 2019-11-27 15:50:47
I am getting the following error code when trying to evaluate a definite integral in Python. AttributeError Traceback (most recent call last) <ipython-input-7-2be8718c68ec> in <module>() 7 x, n = symbols('x n') 8 ----> 9 f = (cos(n*x))*(x**2-pi**2)^2 10 integrate(f,(x,-n*pi,n*pi)) 11 AttributeError: 'Mul' object has no attribute 'cos' I have copied my input code below. Thanks for any help. from pylab import * from sympy import * from numpy import * init_printing(use_unicode=False, wrap_line=False, no_global=True) x, n = symbols('x n') f = (cos(n*x))*(x**2-pi**2)^2 integrate(f,(x,-n*pi,n*pi))

double integral in R

元气小坏坏 提交于 2019-11-27 06:05:20
问题 I'm wondering how to code that takes double integrals in R. I already referred two similar questions. calculating double integrals in R quickly double integration in R with additional argument But I'm still confused how I can get my question from those answers. My question is following. I would like to code this calculations in R. From my hand and Wolfram alpha calculation, it becomes 16826.4. I know how to take a integral if both integrals are from exact numbers using adaptIntegrate(). But I

calculating double integrals in R quickly

杀马特。学长 韩版系。学妹 提交于 2019-11-27 01:36:52
I'm looking for a solution for a double integral that is faster than integrate(function(y) { sapply(y, function(y) { integrate(function(x) myfun(x,y), llim, ulim)$value }) }, llim, ulim) with eg myfun <- function(x,y) cos(x+y) llim <- -0.5 ulim <- 0.5 I found an old paper that referred to a FORTRAN program called quad2d , but I couldn't find anything else but some help pages for matlab for the rest. So I'm looking for a C or FORTRAN library that can do double integrals quick (i.e. without the sapply loop), and that can be called from R. All ideas are very much appreciated, as long as they're

What causes this error (AttributeError: 'Mul' object has no attribute 'cos') in Python?

六眼飞鱼酱① 提交于 2019-11-26 17:19:32
问题 I am getting the following error code when trying to evaluate a definite integral in Python. AttributeError Traceback (most recent call last) <ipython-input-7-2be8718c68ec> in <module>() 7 x, n = symbols('x n') 8 ----> 9 f = (cos(n*x))*(x**2-pi**2)^2 10 integrate(f,(x,-n*pi,n*pi)) 11 AttributeError: 'Mul' object has no attribute 'cos' I have copied my input code below. Thanks for any help. from pylab import * from sympy import * from numpy import * init_printing(use_unicode=False, wrap_line

calculating double integrals in R quickly

萝らか妹 提交于 2019-11-26 09:42:53
问题 I\'m looking for a solution for a double integral that is faster than integrate(function(y) { sapply(y, function(y) { integrate(function(x) myfun(x,y), llim, ulim)$value }) }, llim, ulim) with eg myfun <- function(x,y) cos(x+y) llim <- -0.5 ulim <- 0.5 I found an old paper that referred to a FORTRAN program called quad2d , but I couldn\'t find anything else but some help pages for matlab for the rest. So I\'m looking for a C or FORTRAN library that can do double integrals quick (i.e. without