# Ticket #5562(closed defect: fixed)

Opened 4 years ago

## coercion error with vectors and polynomial rings with 1 variable

Reported by: Owned by: ncalexan was major sage-5.7 linear algebra coercion vector polynomial ring robertwb N/A Travis Scrimshaw Christian Nassau sage-5.7.beta2

### Description

This is strange: it matters how many variables are specified. This fails and I think this is a bug:

```sage: R.<u> = PolynomialRing(RDF, 1, 'u')
sage: v1 = vector([u])
sage: v2 = vector([CDF(2)])
sage: v1 * v2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/ncalexan/sage-3.4.rc0-sage.math-only-x86_64-Linux/devel/sage/sage/functions/riemann_theta.py in <module>()

/home/ncalexan/sage-3.4.rc0-sage.math-only-x86_64-Linux/local/lib/python2.5/site-packages/sage/structure/element.so in sage.structure.el\
ement.Vector.__mul__ (sage/structure/element.c:10435)()

/home/ncalexan/sage-3.4.rc0-sage.math-only-x86_64-Linux/local/lib/python2.5/site-packages/sage/structure/coerce.so in sage.structure.coe\
rce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:5847)()

TypeError: unsupported operand parent(s) for '*': 'Ambient free module of rank 1 over the integral domain Multivariate Polynomial Ring i\
n u over Real Double Field' and 'Vector space of dimension 1 over Complex Double Field'
```

But both of these succeed:

```sage: R.<u, v> = RDF[]
sage: v1 = vector([u])
sage: v2 = vector([CDF(2)])
sage: v1 * v2
2.0*u
```
```sage: R.<u> = RDF[]
sage: v1 = vector([u])
sage: v2 = vector([CDF(2)])
sage: v1 * v2
2.0*u
```

## Change History

### comment:1 Changed 5 months ago by tscrim

• Status changed from new to needs_review
• Report Upstream set to N/A
• Milestone changed from sage-5.6 to sage-duplicate/invalid/wontfix

This seems to be fixed in 5.5.rc0

```sage: R.<u> = PolynomialRing(RDF, 1, 'u')
sage: v1 = vector([u])
sage: v2 = vector([CDF(2)])
sage: v1 * v2
2.0*u
```

### comment:2 Changed 4 months ago by cnassau

I've attached a patch that adds a doctest that makes sure this keeps working.

The patch also removes plenty of trailing whitespace in the affected file. I got this for free by putting

```(add-hook 'before-save-hook 'delete-trailing-whitespace)
```

into my ".emacs.rc".

But maybe it might have been better to just give the "wontfix" a positive review instead...

Last edited 4 months ago by cnassau (previous) (diff)

### comment:3 follow-up: ↓ 4 Changed 4 months ago by tscrim

• Reviewers set to Travis Scrimshaw
• Milestone changed from sage-duplicate/invalid/wontfix to sage-5.7
• Authors set to Christian Nassau

Hey,

For doctest formatting, I would change:

```    sage: # check that #5562 has been fixed
sage: R.<u> = PolynomialRing(RDF, 1, 'u')
...
```

to

```Check that :trac:`5562` has been fixed::

sage: R.<u> = PolynomialRing(RDF, 1, 'u')
...
```

I think the trailing whitespace removal should be okay...

Best,
Travis

### comment:4 in reply to: ↑ 3 Changed 4 months ago by cnassau

Hi Travis,

I agree, in theory, that the doctest should be reformatted. However, I don't know how to do this because the patch has apparently already been merged in 5.7.beta1. Would I create a new patch based on beta1, or edit the old one?

Cheers, Christian

### comment:5 Changed 4 months ago by robertwb

This won't be merged until it's positively reviewed and closed, it's just the target that was changed. You can create a new patch or edit the old, whichever makes it clearer what your changes were.

### comment:6 follow-up: ↓ 7 Changed 4 months ago by tscrim

• Status changed from needs_review to positive_review

Looks good to me. Thanks Christian.