Please consider the following simple and larger example:
varSimple = ToExpression@CharacterRange["a", "b"];
fSimple = Total@Map[Sqrt[#^2] &, varSimple];
assumpSimple = And[Element[varSimple, Integers] , a >= 0 , b >= 0];
simpfSimple = Simplify[fSimple, assumpSimple]
(*a+b*)
When one defines a larger function such as fLarge
, it is very inconvenient to type character1>=0 && ... && character#>=0
for the whole CharacterRange
to define the assumptions.
varLarge = ToExpression@CharacterRange["a", "z"];
fLarge = Total@Map[Sqrt[#^2] &, varLarge];
assumpLarge = And[Element[varLarge, Integers] , a >= 0 , ... , z=>0];
simpfSimple = Simplify[fSimple, assumpLarge]
(*a+...+z*)
Question 1
Since And
(as well as Alternatives
) cannot cope with List
as an argument, how can I combine a larger number of expressions with And
(or Alternatives
)?
Question 2
With ToExpression@CharacterRange["a", "z"]
the number of variables is limited to 24. Is there another (easy) way to define a larger number of variables?
var=ToExpression@ (# <> "1") & /@ CharacterRange["a", "z"]
would produce another 26 ;-) and thenAnd @@ Map[# > 0 &, var]
$\endgroup$