how to express operators in symbolic algebra
조회 수: 3 (최근 30일)
이전 댓글 표시
I want to express an operator, P, which is simply the differential operator. I cannot find how to do this--one failed attempt is shown--any help appreciated
Fritz
==============================================
clear all
syms x
syms P(q), q(x)
q(x)=x^2
P(q) = diff(q(x),1) +5
return
댓글 수: 0
답변 (3개)
Walter Roberson
2023년 12월 17일
MATLAB does not support creating operators: it only supports creating functions and expressions.
For example, P^3 to represent third derivative is not supported by MATLAB.
댓글 수: 0
Paul
2023년 12월 17일
편집: Paul
2023년 12월 17일
I'm not sure how define a function of a function. But this seems to work, at least for this simple case:
syms x t
syms q(t) v(x) % v is our dummy function
P = diff(v,argnames(v),1) + 5 % "operator" P
q(t) = t^2
P(t) % show what P(t) is
subs(P(argnames(q)),v,q) % subs the dummy function with the actual function
Or, more generally w/o needing to know the symfun buried in P
subs(P(argnames(q)),symfun(findSymType(P,'symfun'),symvar(P)),q) % subs the dummy function
I'm not sure this is the best way.
It can probably be wrapped in cleaner functionality, like
operateon = @(P,q) subs(P(argnames(q)),symfun(findSymType(P,'symfun'),symvar(P)),q); % subs the dummy function
operateon(P,q)
Exending to other operations as defined in Matlab
operateon(2*P,q)
operateon(P^3,q)
댓글 수: 6
Dyuman Joshi
2023년 12월 22일
Also, @Fritz Sonnichsen, if this answer solved your problem, please consider accepting the answer. The general idea is to accept the answer that is most fitting to the question asked.
Accepting an answer indicates that your problem has been solved (which can be helpful to other people in future) and it awards the volunteer with reputation points for helping you.
You can accept only 1 answer for a question, but you can vote for as many answers as you want. Voting an answer also provides reputation points.
참고 항목
카테고리
Help Center 및 File Exchange에서 Number Theory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!