Search code examples
c++symbolic-computationsymbolicc++

How to input a symbolic variable in SymbolicC++


I'm making a program that takes input for an expression and integrates it and prints the result to the user. I'm using SymbolicC++, but can't seem to figure out how to input a symbolic... how do I do this - I'm using Visual Studio for my IDE


Solution

  • Like this (example from here):

    #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;
    }