# How to create symbolic rewrite rules with new variables?

**URL:** <https://discourse.julialang.org/t/how-to-create-symbolic-rewrite-rules-with-new-variables/75511>\
**Category:** New to Julia\
**Tags:** symbolic, symbolic-utils\
**Created:** [January 31, 2022, 2:19pm UTC](https://discourse.julialang.org/t/how-to-create-symbolic-rewrite-rules-with-new-variables/75511 "2022-01-31T14:19:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zer0](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zer0/32/33354_2.png) [@Zer0](https://discourse.julialang.org/u/Zer0)\
**Post date:** [January 31, 2022, 2:19pm UTC](https://discourse.julialang.org/t/how-to-create-symbolic-rewrite-rules-with-new-variables/75511/1 "2022-01-31T14:19:04Z")

</div>

Hi all,

I am not sure where to put this topic, and I am still fairly new to Julia. So I put it in “New to Julia”. 😅

I was playing around with symbolic-utils a little. I like the straight forward rule-based rewriting approach.  
But I found no way to introduce new variables in the rewrite rules.

Something like:

```julia
x[1]x[2]x[3] = x[1]*(y_2_3)+Term(y_2_3,x[2],x[3])

```

In words:  
Replace all cubic polynomials with a quadratic one by introducing a new variable y and an additional Term. Preferably, the new variable name should reflect the variables it did replace.

A simpler example:

```julia
x[1]^2+x[2]^2 = (r_1_2)^2

```

Is there any easy way to do this?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 31, 2022, 2:28pm UTC](https://discourse.julialang.org/t/how-to-create-symbolic-rewrite-rules-with-new-variables/75511/2 "2022-01-31T14:28:26Z")

</div>

Open an issue for this one.
