User Input and Derivatives with SymbolicC++

Time Write 1 Reputation point
2021-02-10T20:38:35.757+00:00

Hello, I'm working on a project that requrires that I let the user input a nonlinear function to then have the derivative taken from it using C++. I am attempting to use SymbolicC++ but when taking in the user's input as a string, it takes the entire string as a constant. I tried using this for guidance but I don't think they realized it: https://social.msdn.microsoft.com/Forums/vstudio/en-US/fe63ea49-08bb-4755-ad0d-bcdb6ffeb71b/taking-input-for-symbolic-expressions-in-symbolicc?forum=vcgeneral (or maybe I'm missing something.)

#include <iostream>
#include <string>
#include "symbolicc++.h"
using namespace std;

int main(void)
{

    string inp;
    Symbolic x("x");
    cout << "Input: "; //input: 3*x*x
    getline(cin, inp);
    Symbolic input(inp);
    cout << "Derivative: " << df(input, x); //output: 0
    cout << endl;
    cout << "Integral: " << integrate(input, x); //output: 3*x*x*x
    return 0;
}

If anyone has any suggestions as to what I can do to symbolically take a user's input to find derivatives with SymbolicC++ or some other package in C++ that'd be much appreciated. Additionally this was the only other source of information I could find on the package: http://symboliccpp.sourceforge.net/introsymb.pdf

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,637 questions
{count} votes