How to calculate limit in n-number of times?

조회 수: 1 (최근 30일)
Yanuar Rizki Pahlevi
Yanuar Rizki Pahlevi 2020년 9월 6일
댓글: Yanuar Rizki Pahlevi 2020년 9월 6일
Hi guys, I am working on a function which can generate the differentiation of equation given as input.
But I am trying to make it automatically given answer as input k. if k=1, then it will give the first differentiation, and so on.
and so I put dx^k on my code below, but matlab replied me with limit should be variable only. do you guys have any idea how to make it automatic?
function [Y_1,Y_2]=PolynomialDifferentiation (A,k)
syms x dx
Equation=poly2sym(A)
i=numel(A)
k=1:i-1
Equation_1=subs(Equation,x,(x+dx)); %to calculate F(x+dx)
Y=(Equation_1-Equation)/dx %(F(x+dx)-F(x))/dx
firstDiff=limit(Y,dx,0)%to define first differentiation of given equation
answer=coeffs(firstDiff)
secondEquation=firstDiff
C_1=subs(firstDiff,x,(x+dx));
D=(C_1-firstDiff)/dx;
secondDiff=limit(D,dx,0)
answer=coeffs(secondDiff)

답변 (1개)

Matt J
Matt J 2020년 9월 6일
편집: Matt J 2020년 9월 6일
I can't quite understand what your code is trying to do, but if you are trying to get the k-th derivative of a polynomial, given its coefficients A, you could just do
for i=1:k
A=polyder(A);
end
  댓글 수: 1
Yanuar Rizki Pahlevi
Yanuar Rizki Pahlevi 2020년 9월 6일
Hi, thank you for your response. Yes, i know i can use polyder, but I am trying to not use any polynomial equation at all.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by