Following @slelievre 's comment, here is a possible answer using maps $\mathbb{R} \to \mathbb{R}^2$ and $\mathbb{R}\to\mathbb{R}$:
We define first $f$ as a differentiable map $\mathbb{R} \to \mathbb{R}^2$ :
sage: R.<x> = RealLine()
sage: R2.<X,Y> = EuclideanSpace(name='R^2')
sage: f = R.diff_map(R2, (sin(x), cos(x)))
sage: f.display()
R --> R^2
x |--> (X, Y) = (sin(x), cos(x))
sage: f(x)
Point on the Euclidean plane R^2
sage: f(x).coord()
(sin(x), cos(x))
sage: f(pi).coord()
(0, -1)
One can also access to the coordinate functions representing $f$:
sage: fc = f.coord_functions()
sage: fc
Coordinate functions (sin(x), cos(x)) on the Chart (R, (x,))
sage: fc(x)
(sin(x), cos(x))
sage: fc(pi)
(0, -1)
Then we define $H$ as the differentiable map $\mathbb{R}\to\mathbb{R}$ whose coordinate expression is $h(x)$:
sage: H = R.diff_map(R, function('h')(x))
sage: H.display()
R --> R
x |--> h(x)
and we compose $f$ by $H$ by means of the operator *
:
sage: g = f * H
sage: g
Curve in the Euclidean plane R^2
sage: g.display()
R --> R^2
x |--> (X, Y) = (sin(h(x)), cos(h(x)))
Then
sage: g(x)
Point on the Euclidean plane R^2
sage: g(x).coord()
(sin(h(x)), cos(h(x)))
sage: g(pi).coord()
(sin(h(pi)), cos(h(pi)))
sage: gc = g.coord_functions(); gc
Coordinate functions (sin(h(x)), cos(h(x))) on the Chart (R, (x,))
sage: gc(pi)
(sin(h(pi)), cos(h(pi)))
symbolic_expression(f(h(x))) fails, but symbolic_expression( (sin(h(x)), cos(h(x))) ) succeeds.
SageMath version 9.1, Release Date: 2020-05-20
Using Python 3.7.3.
Hello! By carefully checking the code for
symbolic_expression()
, I can see that the problem actually happens when that command sends its output toSR
. Here is a simpler example:If $f$ is a $\mathbb{R}\rightarrow\mathbb{R}$, instead of $\mathbb{R}\rightarrow\mathbb{R}^2$, there is no error message.
I hope this helps to pinpoint the location of the problem!
A similar example, but using vector: