I’m starting with Symbolics.jl, however I’m stuck with a basic functionality.
I often use sympy to generate some text expressions that I then copy/paste in either C, MATLAB or Julia codes. I was wondering how one could do this with symbolics?
Here’s a sympy example that better illustrates what I mean:
x, a, b, c = symbols('x, a, b, c')
F = a*x**3 + b*x**2 + c*x
print('Julia_expr = ' + julia_code( F.diff(x) ) )
print('Octave_expr = ' + octave_code( F.diff(x) ) )
print('C_expr = ' + ccode( F.diff(x) ) )
Also, one issue here: the ‘Julia_expr’ still needs to be edited before use within Julia (dots are missing )
Thanks for the link. As far as I understand the docs build_function() build functions in different languages and with different types of parallelism.
I was wondering whether there was a also way to create a single line expression just as sympy’s julia_code does?
I could not pick it up from the docs; I’ve searched for wrong key words.
using Symbolics
@variables x a b c
D = Differential(x)
F = a*x^3 + b*x^2 + c*x
dFdx = expand_derivatives(D(F))
build_function(dFdx, x, a, b, c, target=Symbolics.JuliaTarget())
build_function(dFdx, x, a, b, c, target=Symbolics.CTarget())
build_function(dFdx, x, a, b, c, target=Symbolics.MATLABTarget())