# Revision history [back]

### how to factorize an expression with constant variables ?

Hello, I would like to factorize an expression with sage that contains constant variables (i.e. parameters), but I cannot figure out how to do that.

Here is an example : x, y are variables and A is a parameter

var('A x y')

f = Ax + x + A^2exp(y) + y print (f.factor())

Sage returns 'A^2e^y + Ax + x + y'. Instead, I would like that sage returns '(A+1)x + (A^2+1)exp(y)'.

How to do that ? Thank you

 2 No.2 Revision kcrisman 11710 ●34 ●114 ●233

### how to factorize an expression with constant variables ?

Hello, I would like to factorize an expression with sage that contains constant variables (i.e. parameters), but I cannot figure out how to do that.

Here is an example : x, y x, y are variables and A A is a parameter

var('A x y')y')
f = Ax A*x + x + A^2exp(y) A^2*exp(y) + y
print (f.factor()) (f.factor())


Sage returns 'A^2e^y A^2*e^y + Ax A*x + x + y'. y. Instead, I would like that sage returns '(A+1)x (A+1)*x + (A^2+1)exp(y)'.(A^2+1)*exp(y).

How to do that ? Thank you

 3 fix formatting calc314 4051 ●19 ●44 ●107

### how to factorize an expression with constant variables ?

Hello, I would like to factorize an expression with sage that contains constant variables (i.e. parameters), but I cannot figure out how to do that.

Here is an example : x, y are variables and A is a parameter

var('A x y')
y')  f = A*x Ax + x + A^2*exp(y) A^2exp(y) + y
print (f.factor())

(f.factor())

Sage returns A^2*e^y + A*x + x + y. Instead, I would like that sage returns (A+1)*x + (A^2+1)*exp(y).

How to do that ? Thank you

 4 No.4 Revision calc314 4051 ●19 ●44 ●107

### how to factorize an expression with constant variables ?

Hello, I would like to factorize an expression with sage that contains constant variables (i.e. parameters), but I cannot figure out how to do that.

Here is an example : x, y are variables and A is a parameter

var('A x y')y')
f = Ax A*x + x + A^2exp(y) A^2*exp(y) + y
print (f.factor())(f.factor())


Sage returns A^2*e^y + A*x + x + y. Instead, I would like that sage returns (A+1)*x + (A^2+1)*exp(y).

How to do that ? Thank you