PrevUpHome

Start - Giac c++


Install

Get giac source code, install the giac program and giac c++ library.

https://www-fourier.ujf-grenoble.fr/~parisse/giac_us.html

Use giac

Use giac as a calculator

$ giac
0>> 3/4
3/4
// Time 0
1>> 3/5.0
0.6
// Time 0
2>> (7.0-3)/3
1.33333333333
// Time 0

Use giac as mathematical shell

Solve equation:

9>> solve(x^3 + x^2 = 7)
list[-1/374*rootof([[3,0,-5,-187,126],[1,0,-2,0,1,0,1295]])]
// Time 0
10>> solve(x^3 + x^2 = 7.0)
list[1.63109929754]
// Time 0

Solve differential equation:

11>> desolve(y' = x)
(2*c_0+x^2)/2
// Time 0
12>> desolve(y' = e^x)
c_0+exp(x)
// Time 0

Integral:

13>> int(x)
x^2/2
// Time 0
14>> int(int(x))
1/2*x^3/3
// Time 0
15>> int(x^x)
integrate(exp(ln(x)*x+ln(x))/x,x)
// Time 0.01

giac c++ library

Mathematical integral with giac c++:

#include <giac/config.h>
#include <giac/giac.h>
#include <iostream>

int main()
{
	auto g_ctx = giac::context{};
	auto expr = giac::gen{"x^pi", &g_ctx};
	auto integr = giac::_int(expr, &g_ctx);
	integr = giac::_simplify(integr, &g_ctx);
	std::cout << "Expression: " << expr << std::endl;
	std::cout << "Integral: " << integr << std::endl;
}
$ g++ hello.cpp -std=c++23 -lgiac -o hello
$ ./hello
Expression: x^pi
Integral: x^(pi+1)/(pi+1)









Jan 07, 2025

Back

Up

cpp/c++

c++ std::exception:

std::cout.write(err.data(), err.size());

std::cout << std::endl;

caught:

  ===================================
  #  The c++ programming language.  #
  #                                 #
  #  Join c++ Discord: yZcauUAUyC   #
  #  Deck                           #
  ===================================

Home: cppfx.xyz

K


PrevUpHome