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