cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Derivative of a function with vector arguments

JonWarriner
4-Participant

Derivative of a function with vector arguments

I'm using Mathcad Prime 5.0.

 

I have the following function defined.

JonWarriner_0-1578500141838.png

The intent if for this function to be very generic and allow any number of inputs.  Therefore, Vin and Rin are vectors of the same length.  Here's how those are setup.

JonWarriner_1-1578500257064.png

The function itself works fine. 

JonWarriner_2-1578500295197.png

Now, I need to take the derivative of that function with respect to the individual components of Rin.  The intent is to estimate how much effect the variation of each individual component has on the overall output.  Ultimately the expression and number of parameters will be bigger than what I've shown here.  I just scaled everything back to a simpler example to illustrate the actual problem.  I was hoping the derivative with respect to Rin would give me a vector of the numerically evaluated derivative with respect to each individual resistance.  Instead it tells me everything has to be scalar.

JonWarriner_4-1578501004601.png

I found some old posts similar to this dating back to 2004 and 2005.  They basically said this isn't possible.  I was hoping something may have changed in 14 to 15 years.  

 

Thanks,

Jon

4 REPLIES 4


was hoping something may have changed in 14 to 15 years. 

Unfortunately not (apart from the development of Prime which actually is a big step backwards).

You will have to find a workaround which sure is not as generic as you'd like it to be 😞

You can find your work-around on the internet.

Fred,

 

Thanks!  Your approach didn't quite give me what I wanted but it got me thinking.

What I was trying to get was an approximate, linearized effect of each component on the output.  Your solution gave me the sum of the derivatives for each component.  

 

JonWarriner_0-1578515538174.png

But, your approach got me thinking that I was being too lazy in trying to let Mathcad do all of the work.  The partial derivative with respect to each resistor in my input vector just boils down to this:

JonWarriner_1-1578515673374.png

Then, I can just pass my input vector to that function and get my individual results:

JonWarriner_2-1578515745911.png

Thanks,

Jon

Mathcad is a great tool, but not the best one you have.  NASA went to the moon with pencils and slide rules!

 

Glad you got to your solution.

 

BTW, Version 15 will allow you to let partial derivatives show as partials (greek d).  It also has a gradient function (cntrl-shift-G) that would allow partial derivatives of a function of several variables.

Top Tags