ginac库计算偏微分
2020-10-13 本文已影响0人
一路向后
1.程序源码
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
int main()
{
symbol x("x"), y("y");
ex poly;
//z = x^2 + y^2
poly = pow(x,2) + pow(y,2);
//关于x和y的偏微分
cout << poly.diff(x) << endl;
cout << poly.diff(y) << endl;
return 0;
}
2.编译源码
$ g++ -o example example.c -lginac -lcln -I/usr/local/include -L/usr/local/lib64
3.运行结果
./example
2*x
2*y