SymbolicC++
SymbolicC++ is a general purpose computer algebra system written in the programming language C++. It is free software released under the terms of the GNU General Public License. SymbolicC++ is used by including a C++ header file or by linking against a library. Examples#include <iostream>
#include "symbolicc++.h"
using namespace std;
int main(void)
{
Symbolic x("x");
cout << integrate(x+1, x); // => 1/2*x^(2)+x
Symbolic y("y");
cout << df(y, x); // => 0
cout << df(y[x], x); // => df(y[x],x)
cout << df(exp(cos(y[x])), x); // => -sin(y[x])*df(y[x],x)*e^cos(y[x])
return 0;
}
The following program fragment inverts the matrix symbolically. Symbolic theta("theta");
Symbolic R = ( ( cos(theta), sin(theta) ),
( -sin(theta), cos(theta) ) );
cout << R(0,1); // sin(theta)
Symbolic RI = R.inverse();
cout << RI[ (cos(theta)^2) == 1 - (sin(theta)^2) ];
The output is [ cos(theta) −sin(theta) ] [ sin(theta) cos(theta) ] The next program illustrates non-commutative symbols in SymbolicC++. Here #include <iostream>
#include "symbolicc++.h"
using namespace std;
int main(void)
{
// The operator b is the annihilation operator and bd is the creation operator
Symbolic b("b"), bd("bd"), vs("vs");
b = ~b; bd = ~bd; vs = ~vs;
Equations rules = (b*bd == bd*b + 1, b*vs == 0);
// Example 1
Symbolic result1 = b*bd*b*bd;
cout << "result1 = " << result1.subst_all(rules) << endl;
cout << "result1*vs = " << (result1*vs).subst_all(rules) << endl;
// Example 2
Symbolic result2 = (b+bd)^4;
cout << "result2 = " << result2.subst_all(rules) << endl;
cout << "result2*vs = " << (result2*vs).subst_all(rules) << endl;
return 0;
}
Further examples can be found in the books listed below.[1][2][3][4] HistorySymbolicC++ is described in a series of books on computer algebra. The first book[5] described the first version of SymbolicC++. In this version the main data type for symbolic computation was the
Example: #include <iostream>
#include "rational.h"
#include "msymbol.h"
using namespace std;
int main(void)
{
Sum<int> x("x",1);
Sum<Rational<int> > y("y",1);
cout << Int(y, y); // => 1/2 yˆ2
y.depend(x);
cout << df(y, x); // => df(y,x)
return 0;
}
The second version[6] of SymbolicC++ featured new classes such as the Newer versions are available from the SymbolicC++ website. See alsoReferences
External links |
Portal di Ensiklopedia Dunia