Ask Your Question

Wulfsta's profile - activity

2016-11-19 19:41:37 +0100 received badge  Scholar (source)
2016-05-10 18:45:22 +0100 received badge  Famous Question (source)
2016-04-03 20:42:39 +0100 received badge  Notable Question (source)
2016-04-03 20:42:39 +0100 received badge  Popular Question (source)
2015-06-29 08:09:44 +0100 commented answer Unable to Simplify to Float Approximation for a Numerical Integral

Well... this is really quite confusing. I don't completely understand how getnumerical gets passed a value to be plotted, but I think it's just my unfamiliarity with python; I don't find myself using it often. I appreciate the help, I'm really glad it works now!

2015-06-29 04:54:10 +0100 received badge  Editor (source)
2015-06-29 04:29:35 +0100 asked a question Unable to Simplify to Float Approximation for a Numerical Integral

Hello,

I'm trying to approximate a curve, here is my code:

a = 1        # x radius length
b = 1        # y radius length
cut = pi/4   # angle of plane

theta = var('theta')
phi = var('phi')
diffx = diff(a*cos(theta), theta)
diffy = diff(b*sin(theta), theta)
func = (diffx^2+diffy^2)^(1/2)

def getnumerical(i):
    approx = numerical_integral(func, 0, i)
    return approx[0]

parametric_plot((getnumerical(phi), b*sin(phi)*tan(cut)), (phi, 2*pi, 4*pi), aspect_ratio = 1)

The integral defining the x term in the parametric plot is elliptic, so it must be numerically approximated. So far, I have had little success getting any numerical integral methods to work, including nintegral, and am frustrated because I cannot discern the problem. This implementation gives the error:

Traceback (most recent call last):    
  File "", line 1, in <module>

  File "/tmp/tmpDAHxNF/___code___.py", line 17, in <module>
    exec compile(u'parametric_plot((getnumerical(phi), b*sin(phi)*tan(cut)), (phi, _sage_const_2 *pi, _sage_const_4 *pi), aspect_ratio = _sage_const_1 )
  File "", line 1, in <module>

  File "/tmp/tmpDAHxNF/___code___.py", line 14, in getnumerical
    approx = numerical_integral(func, _sage_const_0 , i)
  File "sage/gsl/integration.pyx", line 332, in sage.gsl.integration.numerical_integral (build/cythonized/sage/gsl/integration.c:3159)
  File "sage/symbolic/expression.pyx", line 1177, in sage.symbolic.expression.Expression.__float__ (build/cythonized/sage/symbolic/expression.cpp:8897)
TypeError: unable to simplify to float approximation

Thank you for any help you provide.

Edit: With the constants defined as they currently are, this should plot a sine wave.