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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Define a function, which is the result of a symbolic calculation (rather lenghty)

Manfred_F
12-Amethyst

Define a function, which is the result of a symbolic calculation (rather lenghty)

Can somebody tell me what is wrong with this definition?
See attached Prime8 sheet

 

 

ACCEPTED SOLUTION

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

There is no symbolic simplification necessary!

Simply define your function with the derivatives and evaluate it numerically.

 

You should never have to resort to copy and paste results of a symbolic evaluation to a function definition.

Werner_E_0-1691582661197.png

 

If you really want to see a symbolic result you always can evaluate the defined function symbolically.

Werner_E_1-1691582703946.png

 

But you have to keep in mind that the symbolic unfortunately does not know anything about units, especially temperature units which actually are functions! This seems the reason why copying the symbolic result to a function definition threw that error. The symbolics treated °C just like an unknown variable (which cancelled when using a symbolic evaluation as ttokoro had suggested) instead of the function it actually is, The numeric which knows about units chokes on an expression like °C^2.

 

I won't suggest using the symbolics when you are just after a numeric result.

Alternatively you may calculate the symbolic derivatives, etc. and define and symbolically evaluate your function BEFORE you define any variables. Also use a variable instead of the constant 25° when you do so.

View solution in original post

6 REPLIES 6
ttokoro
20-Turquoise
(To:Manfred_F)

image.png

Werner_E
25-Diamond I
(To:Manfred_F)

There is no symbolic simplification necessary!

Simply define your function with the derivatives and evaluate it numerically.

 

You should never have to resort to copy and paste results of a symbolic evaluation to a function definition.

Werner_E_0-1691582661197.png

 

If you really want to see a symbolic result you always can evaluate the defined function symbolically.

Werner_E_1-1691582703946.png

 

But you have to keep in mind that the symbolic unfortunately does not know anything about units, especially temperature units which actually are functions! This seems the reason why copying the symbolic result to a function definition threw that error. The symbolics treated °C just like an unknown variable (which cancelled when using a symbolic evaluation as ttokoro had suggested) instead of the function it actually is, The numeric which knows about units chokes on an expression like °C^2.

 

I won't suggest using the symbolics when you are just after a numeric result.

Alternatively you may calculate the symbolic derivatives, etc. and define and symbolically evaluate your function BEFORE you define any variables. Also use a variable instead of the constant 25° when you do so.

Manfred_F
12-Amethyst
(To:Werner_E)

Thank you, again I have learned something valuable.

LucMeekes
23-Emerald III
(To:Manfred_F)

I propose an approach as shown in the attached.

 

Success!
Luc

Thanks Luc, my error was thinking that i cannot use the derivative in a function definition. I thought it can only be used in symbolic calculations. And the error message of MathCad was not really helpful:

statistic_error.gif "The argument has to be a scalar or a matrix"

Maybe you can also give me a hint how to improve this problem:
I often get very lengthy formulae by setting up an equation, substitute some variables, solve to a variable and so on. To prevent that I need to scroll to the right on lengthy equations, I often copy the result of a symbolic equation to the next line and continue. Is there a possibility to do "line breaks" in symbolic equations optimum would be an operator like  ---> -|  (symbolic evaluation plus line break, equivalent to +-|  "plus with line break").

One solution I derived from your proposal is to define the equation and assign it to a function, then I can repeat the function and all subsequent symbolic operations on a new line. But then I have to repeat all the operations like:  (only as an example, even if it makes no sense)

SymboliEquation.gif

Seems to be better than copying the result, but will not work in all cases.

 

Thanks Manfred

LucMeekes
23-Emerald III
(To:Manfred_F)

Control of the output of the symbolics in (real Mathcad and) Prime is hard to impossible. What you want (breaking off at an operator) is not available for symbolic output, but it is supported for definitions.

In your example, just the lowest of the three expressions (The one with two substitutes and a solve) should do.

Unless of course you are massively interested in the symbolic output of each individual step.

If you only require numerical out, then consider using the root function, or a solve block.

 

Success!
Luc

Announcements

Top Tags