How do I derive a parametric slope symbolically?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
William Kett
el 14 de Ag. de 2020
Comentada: William Kett
el 14 de Ag. de 2020
I want to have matlab derive a parametric slope symbolically.
In other words, given x and y depend on some parameter, let's say t, if I want the parametric slope, I should get dy/dx = (dy/dt)/(dx/dt). I tried the following below to get this to work:
syms t x(t) y(t)
x = x(t)
y = y(t)
ParametricSlope = diff(y,x)
output:
Error using sym/diff (line 70)
Second argument must be a variable or a nonnegative integer specifying the number of differentiations.
What do I need to change/add to get this to work?
0 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Ag. de 2020
Editada: Walter Roberson
el 14 de Ag. de 2020
I wanted to know if Matlab is able to take the argument diff(y,x) given that x and y are functions of t, and derive and then output the equation diff(y,t)/diff(x,t) on its own. Can Matlab do that?
NO
MATLAB cannot take derivatives with respect to a function. Normal calculus cannot take derivative with respect to a function; you need Calculus of Variations for that.
It is often suggested to substitute a variable for the function, take the derivative with respect to the variable, and then substitute back the function for the variable in the result. However, in order for that to work, the two parts have to be independent, and that is something that you cannot guarantee when you do not know what the functions are.
The closest you can get is to take the hypothesis that the functions are independent, and do the substitution, derivative, substitution route, figure out what the function is, and then go back and test to see whether the derivative holds true.
At some point I posted a specific example of where the technique failed, but unfortunately I have long lost track of that example.
syms X
subs(diff(subs(f, x, X),X),X,x) %change function to symbol, take derivative, subs back
Reminder: this can give incorrect answers if the parts are not truly independent.
3 comentarios
Walter Roberson
el 14 de Ag. de 2020
MATLAB's diff() cannot symbolically take the deriviative of a function with respect to a function, and there is no special function that might handle slopes of parametric curves .
The sequence I showed with subs is only valid some of the time; it works based on a hypothesis, and the hypothesis really should be re-validated once more information is known.
... Sort of like if you did a calculation on an expression that included a division, and you multiply through by the denominator as part of the processing, and solve, then you really should go back later and verify that the denominator was not zero.
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!