Ask Your Question

Revision history [back]

You shoud give us more informations about how x3 and diagAbar were constructed.

If i assume, as @slelievre suggests, that x3 is an element of CIF (Complex Interval Field with 53 bits of precision), then you can see that no method .sech() is implemented for it.

sage: a = CIF(3)
sage: a.sech()
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

You might be confused by the fact that

sage: sech(CIF(3+I))
sech(3+I)

gives you an answer. It is just that the function sech() does not find the method .sech() for CIF(3+I), then it answers by a symbolic expression sech(3), as you can see by typing:

sage: sech(CIF(3+I)).parent()
Symbolic Ring

This does not solves anything, since, if you try to get the value of this symbolic expression by converting it to an element of CIF, at some point Sage will have to evaluate CIF(3+I).sech() which is not implemented.

sage: CIF(sech(CIF(3+I)))
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

As you can check, CIF seems the only field where sech is not implemented:

for field in [RR,RDF,RIF,CC,CDF,CIF,SR]:
    print str(field) + ' - ' +  str(sech(field(1)).parent())
    try:
        print str(field(1).sech()) + ' - ' + str(field(1).sech().parent())
    except Exception as e:
        print e
    print ''

But nothing is lost, as you can do it yourself, since elements of CIF have an exp() method and $sech(x) = \frac{2e^{-x}}{1 + e^{-2x}}$

Just define:

sage: sech = lambda x: 2*exp(-x)/(1+exp(-2*x))

But be careful, when you write

sage: I * sech(x3)
0.0993279274194332?*I

The coercion system will do the multiplication in the Symbolic Ring since I is an element of the Symbolic Ring.

sage: (I * sech(x3)).parent()
Symbolic Ring

Hence, you should just do

sage: CIF(I) * sech(x3)
0.0993279274194332?*I

And now you will be safe.

click to hide/show revision 2
replace reference to x3 by references to a

You shoud give us more informations about how x3 and diagAbar were constructed.

If i assume, as @slelievre suggests, that x3 is an element of CIF (Complex Interval Field with 53 bits of precision), then you can see that no method .sech() is implemented for it.

sage: a = CIF(3)
CIF(3+I)
sage: a.sech()
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

You might be confused by the fact that

sage: sech(CIF(3+I))
sech(3+I)
sech(3+1*I)

gives you an answer. It is just that the function sech() does not find the method .sech() for CIF(3+I), then it answers by a symbolic expression sech(3)sech(3+1*I), as you can see by typing:

sage: sech(CIF(3+I)).parent()
Symbolic Ring

This does not solves anything, since, if you try to get the value of this symbolic expression by converting it to an element of CIF, at some point Sage will have to evaluate CIF(3+I).sech() which is not implemented.

sage: CIF(sech(CIF(3+I)))
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

As you can check, CIF seems the only field where sech is not implemented:

for field in [RR,RDF,RIF,CC,CDF,CIF,SR]:
    print str(field) + ' - ' +  str(sech(field(1)).parent())
    try:
        print str(field(1).sech()) + ' - ' + str(field(1).sech().parent())
    except Exception as e:
        print e
    print ''

But nothing is lost, as you can do it yourself, since elements of CIF have an exp() method and $sech(x) = \frac{2e^{-x}}{1 + e^{-2x}}$

Just define:

sage: sech = lambda x: 2*exp(-x)/(1+exp(-2*x))

But be careful, when you write

sage: I * sech(x3)
0.0993279274194332?*I
sech(a)
0.0837533280462231? + 0.0540446576423634?*I

The coercion system will do the multiplication in the Symbolic Ring since I is an element of the Symbolic Ring.

sage: (I * sech(x3)).parent()
sech(a)).parent() Symbolic Ring

Hence, you should just do

sage: CIF(I) * sech(x3)
0.0993279274194332?*I
sech(a)
0.0837533280462231? + 0.0540446576423634?*I

And now you will be safe.

You shoud give us more informations about how x3 and diagAbar were constructed.

If i assume, as @slelievre suggests, that x3 is an element of CIF (Complex Interval Field with 53 bits of precision), then you can see that no method .sech() is implemented for it.

sage: a = CIF(3+I)
sage: a.sech()
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

You might be confused by the fact that

sage: sech(CIF(3+I))
sech(3+1*I)

gives you an answer. It is just that the function sech() does not find the method .sech() for CIF(3+I), then it answers by a symbolic expression sech(3+1*I), as you can see by typing:

sage: sech(CIF(3+I)).parent()
Symbolic Ring

This does not solves anything, since, if you try to get the value of this symbolic expression by converting it to an element of CIF, at some point Sage will have to evaluate CIF(3+I).sech() which is not implemented.

sage: CIF(sech(CIF(3+I)))
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

As you can check, CIF seems the only field where sech is not implemented:

for field in [RR,RDF,RIF,CC,CDF,CIF,SR]:
    print str(field) + ' - ' +  str(sech(field(1)).parent())
    try:
        print str(field(1).sech()) + ' - ' + str(field(1).sech().parent())
    except Exception as e:
        print e
    print ''

But nothing is lost, as you can do it yourself, since elements of CIF have an exp() method and $sech(x) = \frac{2e^{-x}}{1 + e^{-2x}}$

Just define:

sage: sech = lambda x: 2*exp(-x)/(1+exp(-2*x))

But be careful, when you write

sage: I * sech(a)
0.0837533280462231? + 0.0540446576423634?*I

The coercion system will do the multiplication in the Symbolic Ring since I is an element of the Symbolic Ring.

sage: (I * sech(a)).parent()
Symbolic Ring

Ring

Hence, you should just do

sage: CIF(I) * sech(a)
0.0837533280462231? + 0.0540446576423634?*I

And now you will be safe.

You shoud give us more informations about how x3 and diagAbar were constructed.

If i assume, as @slelievre suggests, that x3 is an element of CIF (Complex Interval Field with 53 bits of precision), then you can see that no method .sech() is implemented for it.it:

sage: a = CIF(3+I)
sage: a.sech()
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

You might be confused by the fact that

sage: sech(CIF(3+I))
sech(3+1*I)

gives you an answer. It is just that the function sech() does not find the method .sech() for CIF(3+I), then it answers by a symbolic expression sech(3+1*I), as you can see by typing:

sage: sech(CIF(3+I)).parent()
Symbolic Ring

This does not solves anything, since, if you try to get the value of this symbolic expression by converting it to an element of CIF, at some point Sage will have to evaluate CIF(3+I).sech() which is not implemented.implemented:

sage: CIF(sech(CIF(3+I)))
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no attribute 'sech'

As you can check, CIF seems the only field where sech is not implemented:

for field in [RR,RDF,RIF,CC,CDF,CIF,SR]:
    print str(field) + ' - ' +  str(sech(field(1)).parent())
    try:
        print str(field(1).sech()) + ' - ' + str(field(1).sech().parent())
    except Exception as e:
        print e
    print ''

But nothing is lost, as you can do it yourself, since elements of CIF have an exp() method and $sech(x) = \frac{2e^{-x}}{1 + e^{-2x}}$e^{-2x}}$.

Just define:

sage: sech = lambda x: 2*exp(-x)/(1+exp(-2*x))

But be careful, when you write

sage: I * sech(a)
0.0837533280462231? + 0.0540446576423634?*I

The the coercion system will do the multiplication in the Symbolic Ring since I is an element of the Symbolic Ring.

sage: (I * sech(a)).parent()
Symbolic Ring

Hence, you should just do do:

sage: CIF(I) * sech(a)
0.0837533280462231? + 0.0540446576423634?*I

And now you will be safe.

safe, with respect to the fact that our sech function did not try to minimize the dimaeters of the intervals defining the output, as much as could have done a direct .sech() method defined for elements of CIF.

You shoud give us more informations about how x3 and diagAbar were constructed.

If i assume, as @slelievre suggests, that x3 is an element of CIF (Complex Interval Field with 53 bits of precision), then you can see that no method .sech() is implemented for it:

sage: a = CIF(3+I)
sage: a.sech()
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object  has no attribute 'sech'

You might be confused by the fact that

sage: sech(CIF(3+I))
sech(3+1*I)

gives you an answer. It is just that the function sech() does not find the method .sech() for CIF(3+I), then it answers by a symbolic expression sech(3+1*I), as you can see by typing:

sage: sech(CIF(3+I)).parent()
Symbolic Ring

This does not solves anything, since, if you try to get the value of this symbolic expression by converting it to an element of CIF, at some point Sage will have to evaluate CIF(3+I).sech() which is not implemented:

sage: CIF(sech(CIF(3+I)))
AttributeError: 'sage.rings.complex_interval.ComplexIntervalFieldElement' object  has no attribute 'sech'

As you can check, CIF seems the only field where sech is not implemented:

for field in [RR,RDF,RIF,CC,CDF,CIF,SR]:
    print str(field) + ' - ' +  str(sech(field(1)).parent())
    try:
        print str(field(1).sech()) + ' - ' + str(field(1).sech().parent())
    except Exception as e:
        print e
    print ''

But nothing is lost, as you can do it yourself, since elements of CIF have an exp() method and $sech(x) = \frac{2e^{-x}}{1 + e^{-2x}}$.

Just define:

sage: sech = lambda x: 2*exp(-x)/(1+exp(-2*x))

But be careful, when you write

sage: I * sech(a)
0.0837533280462231? + 0.0540446576423634?*I

the coercion system will do the multiplication in the Symbolic Ring since I is an element of the Symbolic Ring.

sage: (I * sech(a)).parent()
Symbolic Ring

Hence, you should just do:

sage: CIF(I) * sech(a)
0.0837533280462231? + 0.0540446576423634?*I

And now you will be safe, with respect to the fact that our sech function did not try to minimize the dimaeters of the intervals defining the output, as much as could have done a direct .sech() method defined for elements of CIF.