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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Calculation of Derivatives - Create Mathcad Program/Function

Cornel
17-Peridot

Calculation of Derivatives - Create Mathcad Program/Function

Hello,

I would like to get a program in Mathcad that: given being a function with a certain number of parameters and a certain symbolic expression, f (p1, p2, p3, p4, ..., pn): = a certain symbolic expression that involves these parameters: p1, p2, p3, ... ,pn, to automatically obtain the following:

1.  Symbolic calculation of:

CornelBejan_1-1656590551502.png

 

2. Numerical calculation of:

Given finally the numerical values ​​for the parameters: p1, p2, p3, ..., pn, calculate the numerical values ​​for the expressions of the derivatives from point 1.

Example for the case with 3 variables: p1, p2, p3:

CornelBejan_3-1656590786428.png

 

1. Symbolic calculation:

CornelBejan_4-1656590804089.png

 

2. Numerical calculation

CornelBejan_5-1656590822354.png

 

The idea is that I want a Mathcad program that calculates automatically what I want regarding the two points above (point 1 and point 2), meaning to give me as output both the symbolic calculations and the numerical calculations, in the form of parameters, as shown for example in the example above (Sp1, Sp2, Sp3, Sp4, Sp5, Sp6), and not me each time to calculate in turn them one by one, line by line.

 

Attached is the Mathcad file in Mathcad 15, Mathcad 11 and Mathcad Prime 7.0.0 versions.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:Cornel)

You could define a vector function and use the gradient/Nabla operator:

Werner_E_0-1656619113824.png

Of course you could also turn your existing function in a three separate arguments into a vector function

Werner_E_0-1656671363717.png

But I guess it would not hard to write a function which can deal with input functions with a variable number of arguments. Even if you provide that number as a separate argument to your function.

 

View solution in original post

2 REPLIES 2
Werner_E
24-Ruby V
(To:Cornel)

You could define a vector function and use the gradient/Nabla operator:

Werner_E_0-1656619113824.png

Of course you could also turn your existing function in a three separate arguments into a vector function

Werner_E_0-1656671363717.png

But I guess it would not hard to write a function which can deal with input functions with a variable number of arguments. Even if you provide that number as a separate argument to your function.

 

LucMeekes
23-Emerald III
(To:Cornel)

You can define such a function as follows (in Mathcad 11, may work in Mathcad 15, will NOT work in Prime):

LucMeekes_0-1657228936519.png

Your example:

LucMeekes_1-1657228981872.png

Another example:

LucMeekes_2-1657229013162.png

Success!
Luc

Top Tags