Hi all,

I was wondering if there is any standard way in C++ (perhaps in the standard library) of handling mathematical equations that are composed of +/- signs.

For instance, if you are given the equations:

y = +/- sqrt(x)

z = +/- y

Is there an efficient way to deal with equations?

I've tried first naively to program all the possible cases, but the problem stems from the fact that if you have a series of these kinds of equations that all depend on each other, the numbers of equations grows to a point at which it's not really sensible to work out all the cases explicitly. By this I mean coding:

```
yPlus = sqrt(x);
yMinus = -sqrt(x);
zPlusyPlus = sqrt(x);
zPlusyMinus = -sqrt(x);
zMinusyPlus = -sqrt(x);
zMinusyMinus = sqrt(x);
```

Then I tried to program it with vectors/arrays such that:

```
y.push_back( sqrt(x) );
y.push_back( -sqrt(x) );
for ( unsigned int i=0; i<y.size(); i++)
{
z.push_back( y[i] );
z.push_back( -y[i] );
}
```

to result in all the possible combinations.

I am not sure if this is an efficient way of coding however and was wondering if there is maybe a well-established way of dealing with equations that take a piecewise character like the ones given here. I've given the example here in terms of the sqrt(); function, but it equally applies to the trigonometric functions i.e., sin(), cos().

Anyway input would be greatly appreciated.

Thanks,

Kartik