Does Symbolic Math Toolbox Formally Support Function Composition?

31 visualizaciones (últimos 30 días)
Paul
Paul el 19 de Nov. de 2025 a las 1:01
Comentada: Paul el 19 de Nov. de 2025 a las 3:42
The doc page Create Symbolic Functions states "The Symbolic Math Toolbox™ currently does not support composite symbolic functions, or symbolic functions that are functions of another symbolic functions."
But we can do
syms f(x) h(x)
y(x) = f(h(x))
y(x) = 
Is y not a composite, symbolic function?
The chain rule works as well
dy(x) = diff(y(x),x)
dy(x) = 
Is the doc wrong or am I misunderstanding the quoted statement?

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Nov. de 2025 a las 3:06
This is not legal:
syms f(x) g(x)
h(f, g) = f + g
Error using indexing (line 235)
Indexing values must be positive integers, logicals, or symbolic variables. For 'symfun' data type, indexing means evaluating the function for the given value. See also 'subs'.

Error in sym/privsubsasgn (line 1183)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in indexing (line 1030)
C = privsubsasgn(L,R,inds{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  3 comentarios
Walter Roberson
Walter Roberson el 19 de Nov. de 2025 a las 3:10
In other words, symbolic function definitions cannot accept functions as parameters; they can only accept symbolic variables that you pass in symbolic functions in place of.
syms f(x) g(x) F G
h(F,G) = F + G
h(F, G) = 
h(f, g)
ans = 
Paul
Paul el 19 de Nov. de 2025 a las 3:42
Fair enough. But that quoted statement from the doc page should be updated along the lines of defining composite functions via symfun (or its shortcut notation) is what's not supported, as opposed to not supporting composite functions at all, which seems to be clearly not the case.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2025b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by