DrakeTruber
DrakeTruber

Reputation: 337

Algebra Solving and Derivatives?

I have no idea if this is even remotely possible (I looked up "computing algebra" etc with discouraging results). How can one compute Algebra and find Derivatives with Unity?

For example, simplifying the distance formula with one variable (x unkown, some function f(x) known):

d = sqrt( (int-x)^2 + (int-f(x))^2 );

and then finding the derivative of this simplified expression?:

d=>d'

Thank you for your time and any light you can shed on this question. And once again, I have no idea if algebraic operations are even commonplace among most programs, let alone Unity-script specifically.

I have also noticed a few systems claiming algebra manipulation (e.g. http://coffeequate.readthedocs.org/en/latest/), but even if this is so how would one go about applying these systems to unity?

Upvotes: 1

Views: 1264

Answers (1)

sowrd299
sowrd299

Reputation: 149

If you are writing in C#, you can pull off derivatives with delegates and the definition of a derivative, like this:

delegate double MathFunc(double d);
MathFunc derive(MathFunc f, float h) {
    return (x) => (f(x+h) - f(x)) / h;
}

where f in the function you are taking the derivative of, and h determines how accurate your derivative is.

Upvotes: 1

Related Questions