Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.8K Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to assume real variables?

Posted 3 years ago

If you have an expression that contains variables, i.e. non-numeric symbols, and you want to simplify that expression assuming that all variables are real: How can that be achieved?

Unfortunately Simplify[expr,Reals] like in Solve is accepted, but the assumption "Reals" is ignored.

An example with expected result Abs[1+x]:

Block[{x, expr},
 expr = Sqrt[(1 + 2 Conjugate[x] + x^2)];
 {expr, Simplify[expr, Reals], Simplify[expr, Element[x,Reals]]}
 ]

==>

{Sqrt[1 + x^2 + 2 Conjugate[x]], Sqrt[1 + x^2 + 2 Conjugate[x]], Abs[1 + x]}

Of course I could use the last syntax Simplify[expr, Element[x, Reals]] but only if I knew the variables within expr. Often expr or its predecessors are unknown since passed into a function as a parameter. Then, before simplification, I had to scan the complete expr for its variables.

POSTED BY: Werner Geiger
2 Replies
Posted 3 years ago
POSTED BY: Werner Geiger
Posted 3 years ago

Hi Werner,

Not sure if this will work for your actual use case, but you can specify that all symbols are Reals, e.g.

Block[{x, expr},
 expr = Sqrt[(1 + 2 Conjugate[x] + x^2)];
 {expr, Simplify[expr, Reals, Assumptions -> Element[_Symbol, Reals]]}]
(* {Sqrt[1 + x^2 + 2 Conjugate[x]], Abs[1 + x]} *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard