Skip to main content
12-Amethyst
August 9, 2023
Solved

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

  • August 9, 2023
  • 3 replies
  • 2486 views

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

 

 

Best answer by Werner_E

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.

3 replies

ttokoro
21-Topaz I
August 9, 2023

image.png

t.t.
Werner_E25-Diamond IAnswer
25-Diamond I
August 9, 2023

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_F12-AmethystAuthor
12-Amethyst
August 9, 2023

Thank you, again I have learned something valuable.

23-Emerald IV
August 9, 2023

I propose an approach as shown in the attached.

 

Success!
Luc

Manfred_F12-AmethystAuthor
12-Amethyst
August 10, 2023

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

23-Emerald IV
August 11, 2023

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