# algebraic substitution

How can I imitate the **algsubs** function of **Maple**? A little example:

p = x^18

algsubs(x^2=x+1,p)

The reult in **Maple** is:

x^9+9

x^8+36x^7+84x^6+126x^5+126x^4+84x^3+36x^2+9x+1.

algebraic substitution

How can I imitate the **algsubs** function of **Maple**? A little example:

p = x^18

algsubs(x^2=x+1,p)

The reult in **Maple** is:

x^9+9

x^8+36x^7+84x^6+126x^5+126x^4+84x^3+36x^2+9x+1.

1

It seems that there are not the same function in sagemath but we can use " ratsubst " function of maxima

```
sage : maxima('p:x^18')
sage : maxima('ratsubst(a+1,x^2,p)')
```

-1

```
var('y')
P = x^18
eqn = x^2 == y + 1
soln = solve(eqn,x)
P = P.subs(x=soln[0].rhs())
P.expand().subs(y=x)
```

Asked: **
2014-02-06 04:38:29 -0600
**

Seen: **500 times**

Last updated: **Feb 07 '14**

Substitution using Dictionary with Matrix as Value

sqrt function not working properly

How do I make functional substitutions?

Substituting derivative in equation

Is it possible to define (or assume) the derivative of a function

incomplete substitution of expression

Substitute piecewise function variable

Substituting for a matrix of variables

Substituting a particular value for a parameter

Substitute formal function by an expression in a differential equation

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

What is the mathematical meaning of this function ? If you want `x^2` to be equal to `x+1`, then the optimal result would be a polynomial of degree 1, namely `2584*x + 1597`.