Hi all,

I am trying to write a function to solve an equation for one of its variables.

E.g.

X + Y + Z = 0

This equation would be represented by its parameters: parameters[0] is X, parameters[1] is Y, parameters[2] is Z.

If the user wants to solve for X, they would have to provide Y and Z. Likewise for solving for another parameter (if they want to solve Y, they must provide X and Z).

I am thinking of doing this by requiring them to pass an array of the values of X,Y, and Z, and the index of the one they want to solve for. For example, if they want to solve X, they would do:

parameters = {unused, 3.4, 5.6};

Solve(parameters, 0)

Is there some reasonable way of writing the internals of this function besides providing a giant switch statement?

```
if(paramToSolve == 0)
{
X = -Y - Z;
}
else if(paramToSolve == 1)
{
Y = -X - Z;
}
....
```

This gets really annoying when the model/equation gets bigger.

I am trying not to have to break out some big symbolic solver library or something like that, but it seems like that's basically what I'm asking for :)

Thoughts?

Thanks,

David