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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Translate the entire conversation x

Derivative of function

karolp10
3-Newcomer

Derivative of function

Good Morning,

 

I have encountered a problem solving a symbolic equation using Mathcad Prime 11.0.0.0. I try to evaluate the derivative of function using keywords from Sybolics (Operators and Symbols).

The error is: "More than one independent variable for keyword solve.

What I try to do is to find when the derivative of the function is equal zero. To find max/min of a function.

One variable in function f(x) is x. The rest is defined above. So I do not understand what the problem is here. Variable x should be in metres , from range 0 to 1.

Please see below. Also file in attachment.

KP_10397387_1-1758720209477.png

 

 

 

What did I wrong? Is there a better way to find a solution? Anyone could help? How to do it properly?

 

Kind Regards

Karol

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:karolp10)

Problem among other is the inability of Primes symbolics to deal with units. Units are seen as unknown variables, hence the error message. So you should specify which variable to solve for by using "solve,x" and not just "solve".

When using symbolic calculation with units its a good idea to turn on the calculation option seen here

Werner_E_0-1758723206022.png

You must have the sheet recalculated for the change to take effect.

Prime's symbolics still does not know anything about units, but at least setting this option should assure that units are not get labelled wrongly as variables so subsequent numeric calculations would fail.

 

Furthermore when you tried to get rid of the units you made a mistake. The correct way is shown here and as you can see the symbolics actually comes up with a solution:

Werner_E_1-1758723391079.png

Another fix would be this (Pay attention to the length of each fraction bar!)

Werner_E_3-1758726507106.png

 

But it would not be necessary to get rid of the units at all:

Werner_E_2-1758723505307.png

 

Last but not least - as you are just after a numeric result its most of the times better to avoid symbolic calculations and just use numeric methods. Prime offers a solve block with "find" (ugly looking and space consuming, but valuable if you need to apply additional constraints) and also the "root" function which could be used either by providing a guess value or by providing an interval:

Werner_E_0-1758724514526.png

 

Prime 11 sheet attached

 

EDIT: Added the method using a solve block with "find" in the attached sheet.

View solution in original post

5 REPLIES 5
StuartBruff
23-Emerald IV
(To:karolp10)

Hi, Karol

 

Where do you expect to find the minimum and maximum of the function?  Are you sure it's got a finite one?

 

 

2025 09 24 E.png

 

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

15 cm is not the best choice for the last value.
Sometimes size does matter. 🙂

Werner_E_2-1758726149311.png

 

 

Werner_E
25-Diamond I
(To:karolp10)

Problem among other is the inability of Primes symbolics to deal with units. Units are seen as unknown variables, hence the error message. So you should specify which variable to solve for by using "solve,x" and not just "solve".

When using symbolic calculation with units its a good idea to turn on the calculation option seen here

Werner_E_0-1758723206022.png

You must have the sheet recalculated for the change to take effect.

Prime's symbolics still does not know anything about units, but at least setting this option should assure that units are not get labelled wrongly as variables so subsequent numeric calculations would fail.

 

Furthermore when you tried to get rid of the units you made a mistake. The correct way is shown here and as you can see the symbolics actually comes up with a solution:

Werner_E_1-1758723391079.png

Another fix would be this (Pay attention to the length of each fraction bar!)

Werner_E_3-1758726507106.png

 

But it would not be necessary to get rid of the units at all:

Werner_E_2-1758723505307.png

 

Last but not least - as you are just after a numeric result its most of the times better to avoid symbolic calculations and just use numeric methods. Prime offers a solve block with "find" (ugly looking and space consuming, but valuable if you need to apply additional constraints) and also the "root" function which could be used either by providing a guess value or by providing an interval:

Werner_E_0-1758724514526.png

 

Prime 11 sheet attached

 

EDIT: Added the method using a solve block with "find" in the attached sheet.

karolp10
3-Newcomer
(To:Werner_E)

This is exactly what I needed. Many thanks for the very important information relating to ways of solving this issue. What I notice is that the solve block is faster in that matter than symbolic calculation.

Werner_E
25-Diamond I
(To:karolp10)


@karolp10 wrote:

This is exactly what I needed. Many thanks for the very important information relating to ways of solving this issue. What I notice is that the solve block is faster in that matter than symbolic calculation.


@karolp10 

I would guess that the numeric "root" function is equally fast than a numeric solve block. But it's sure no surprise that symbolic calculation is much slower.

Symbolic calculation should be used if for some reason you need a non-numeric, symbolic result. But you must keep in mind that the symbolics will often fail and will not be able to solve more complicated and complex equations.

In your case you could define function f(x) before any variables are defined and symbolically solve  f'(x)=0 for x.

Werner_E_0-1758895338210.png

The red error in the definition of f(x) stems from the numeric engine (variable not defined) and does not interfere with symbolic calculations.

The result is assigned a function in the relevant variables. The expression highlighted in yellow is a constant (independent from x) factor and so has no effect if we are looking for the zero of the derivative. Variables which only occur in this factor are not relevant for the result.

After we have defined a function  'dopt' we can define variables and numerically evaluate it and we can also see how the change of one ore some variables influence the result and compare them side by side.

Werner_E_1-1758895586951.png

If a scenario like this is valuable and desired, then using the symbolic 'solve' makes sense.

If only one numeric result is to be looked for, usually using numerical methods ("root" function, solve block with "find") are preferable.

 

If its of interest how changing one specific value of the four which are relevant for dopt affects the result, you could define an appropriate function and visualize the dependency in a 2D plot. Here for example the effect of changing the value of k.

Werner_E_2-1758896659741.png

 

Announcements

Top Tags