Does Symbolic Math Toolbox Formally Support Function Composition?

31 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2025-11-19,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 个评论
Walter Roberson
Walter Roberson 2025-11-19,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 2025-11-19,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.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by