# How to convert a multivariable polynomial with integer coefficients to one with Float64 coefficients?

**URL:** https://discourse.julialang.org/t/how-to-convert-a-multivariable-polynomial-with-integer-coefficients-to-one-with-float64-coefficients/66438
**Category:** General Usage
**Created:** [August 15, 2021, 1:48pm UTC](https://discourse.julialang.org/t/how-to-convert-a-multivariable-polynomial-with-integer-coefficients-to-one-with-float64-coefficients/66438 "2021-08-15T13:48:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![geo](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@geo](https://discourse.julialang.org/u/geo)
#### Post date: [August 15, 2021, 1:48pm UTC](https://discourse.julialang.org/t/how-to-convert-a-multivariable-polynomial-with-integer-coefficients-to-one-with-float64-coefficients/66438/1 "2021-08-15T13:48:58Z")

</div>

The following code works, but seems ugly. There should be a better way to convert than multiplying by 1.0!  
using DynamicPolynomials  
@polyvar x[1:3]  
m = monomials(x, 0:3)  
mD = differentiate.(m, x[1]) \*1.0

---

<div class="post-metadata">

### Author: ![genkuroki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/genkuroki/32/18030_2.png) [@genkuroki](https://discourse.julialang.org/u/genkuroki)
#### Post date: [August 15, 2021, 2:34pm UTC](https://discourse.julialang.org/t/how-to-convert-a-multivariable-polynomial-with-integer-coefficients-to-one-with-float64-coefficients/66438/2 "2021-08-15T14:34:06Z")

</div>

Please quote the code by enclosing it in triple-backticks. See [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

Conversion can be done with `convert`:

```julia
using DynamicPolynomials
@polyvar x[1:3]
m = monomials(x, 0:3)
mD = differentiate.(m, x[1]) * 1.0
mD2 = convert.(Term{true, Float64}, differentiate.(m, x[1]))
mD2 == mD

```

```julia
true

```

This can be easily seen in the source code:

- [https://github.com/JuliaAlgebra/DynamicPolynomials.jl/blob/master/src/term.jl#L12-L14](https://github.com/JuliaAlgebra/DynamicPolynomials.jl/blob/master/src/term.jl#L12-L14)
- [https://github.com/JuliaAlgebra/DynamicPolynomials.jl/blob/master/src/poly.jl#L38-L41](https://github.com/JuliaAlgebra/DynamicPolynomials.jl/blob/master/src/poly.jl#L38-L41)

If you want to be comfortable, you should also take a look at the source code.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [August 15, 2021, 5:42pm UTC](https://discourse.julialang.org/t/how-to-convert-a-multivariable-polynomial-with-integer-coefficients-to-one-with-float64-coefficients/66438/3 "2021-08-15T17:42:57Z")

</div>

> [@genkuroki](#):
>
> Conversion can be done with `convert` :

It would be nice if it also supported a `float(poly)` method…
