Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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')

def getnumerical(i):
    diffx = diff(a*cos(theta), theta)
    diffy = diff(b*sin(theta), theta)
    func = (diffx^2+diffy^2)^(1/2)
    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.

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')

def getnumerical(i):
    diffx = diff(a*cos(theta), theta)
    diffy = diff(b*sin(theta), theta)
    func = (diffx^2+diffy^2)^(1/2)
    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.

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')

def getnumerical(i):
    diffx = diff(a*cos(theta), theta)
    diffy = diff(b*sin(theta), theta)
    func = (diffx^2+diffy^2)^(1/2)
    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.

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):
    diffx = diff(a*cos(theta), theta)
    diffy = diff(b*sin(theta), theta)
    func = (diffx^2+diffy^2)^(1/2)
    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.