z=1; numerical_integral(exp(i*(x*z+(x^3)/3)), 0, 1, max_points=100)
returns the error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-a00a879c8f90> in <module>()
----> 1 z=Integer(1); numerical_integral(exp(i*(x*z+(x**Integer(3))/Integer(3))), Integer(0), Integer(1), max_points=Integer(100))
/usr/lib/python2.7/site-packages/sage/calculus/integration.pyx in sage.calculus.integration.numerical_integral (build/cythonized/sage/calculus/integration.c:2943)()
279 to_sub = dict(zip(vars[1:], params))
280 func = func.subs(to_sub)
--> 281 func = func._fast_float_(str(vars[0]))
282 except (AttributeError):
283 pass
/usr/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._fast_float_ (build/cythonized/sage/symbolic/expression.cpp:62032)()
11928 """
11929 from sage.symbolic.expression_conversions import fast_float
> 11930 return fast_float(self, *vars)
11931
11932 def _fast_callable_(self, etb):
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in fast_float(ex, *vars)
1704 1.4142135623730951
1705 """
-> 1706 return FastFloatConverter(ex, *vars)()
1707
1708 #################
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
224 return self.tuple(ex)
225 else:
--> 226 return self.composition(ex, operator)
227
228 def get_fake_div(self, ex):
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in composition(self, ex, operator)
1679 """
1680 f = operator
-> 1681 g = [self(_) for _ in ex.operands()]
1682 try:
1683 return f(*g)
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
216 div = self.get_fake_div(ex)
217 return self.arithmetic(div, div.operator())
--> 218 return self.arithmetic(ex, operator)
219 elif operator in relation_operators:
220 return self.relation(ex, operator)
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
1651 from sage.functions.all import sqrt
1652 return sqrt(self(operands[0]))
-> 1653 fops = map(self, operands)
1654 if operator == add_vararg:
1655 operator = _operator.add
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
215 if getattr(self, 'use_fake_div', False) and (operator is _operator.mul or operator is mul_vararg):
216 div = self.get_fake_div(ex)
--> 217 return self.arithmetic(div, div.operator())
218 return self.arithmetic(ex, operator)
219 elif operator in relation_operators:
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
1651 from sage.functions.all import sqrt
1652 return sqrt(self(operands[0]))
-> 1653 fops = map(self, operands)
1654 if operator == add_vararg:
1655 operator = _operator.add
/usr/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
206 except TypeError as err:
207 if 'self must be a numeric expression' not in err.args:
--> 208 raise err
209
210 operator = ex.operator()
TypeError: unable to coerce to a real number
Likewise:
z=1; integral(exp(i*(x*z+(x^3/3))), x, 0, +Infinity)
returns:
integrate(e^(1/3*I*x^3 + I*x), x, 0, +Infinity)
. If I add a .n()
after it, to numerically evaluate it, I get much the same error as I showed earlier. So, how can I do numerical integration of complex integrands in SageMath? I know that simple complex integrands (e.g. exp(i*x)
) can be analytically integrated by SageMath, but numerical integration does not seem to be an option.