But for the case described above (and feel free to use this as a starting point to write your own comprehensive symbolic manipulation module), you can do:
$string =~ s/ //gs; # remove spaces $string =~ s/\((\w+)\*(\d+)\)\+\(\1\*(\d+))/($1\*(?{$2+$3})\)/gsx;
Which should do only exactly the substitution you describe above. (Needs testing)
In reply to Re: minimizing simple linear equations
by dynamo
in thread minimizing simple linear equations
by beemshake
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |