Does Symbolic Math Toolbox Formally Support Function Composition?

31 ビュー (過去 30 日間)
Paul
Paul 2025 年 11 月 19 日 1:01
コメント済み: Paul 2025 年 11 月 19 日 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?

採用された回答

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