Functions As Arguments - Passing functions containing programming elements to other functions. Order of ops with temperature - Сообщения
In order to minimize repeated blocks of operations, I found a need to pass a function which contains programming elements to another function or program. It would appear that this is either not possible, or more probably, I am doing something wrong.
I have attached a simplified case that exhibits the issue.
WhatAmIDoingWrong1.sm (9 КиБ) скачан 80 раз(а).
Would someone please let me know what I am doing wrong?
THANKS!
-Jeff
P.S. Additionally I found that negative values with temperature units requires parentheses.
The matter is to dress correctly.
Two typical examples. The Gaussian
spot take ~ 12 sec to show image.
Let it run.
Jean
Utilities Discrete Algo Range.sm (17 КиБ) скачан 68 раз(а).
WroteI ran into a couple of issues while running some calculations.
In order to minimize repeated blocks of operations, I found a need to pass a function which contains programming elements to another function or program. It would appear that this is either not possible, or more probably, I am doing something wrong.
I have attached a simplified case that exhibits the issue.
WhatAmIDoingWrong1.sm (9 КиБ) скачан 80 раз(а).
Would someone please let me know what I am doing wrong?
THANKS!
-Jeff
Hello Jeff,
I think this might be a bug

Regards,
Radovan
WroteI ran into a couple of issues while running some calculations.
In order to minimize repeated blocks of operations, I found a need to pass a function which contains programming elements to another function or program. It would appear that this is either not possible, or more probably, I am doing something wrong.
I have attached a simplified case that exhibits the issue.
WhatAmIDoingWrong1.sm (9 КиБ) скачан 80 раз(а).
Would someone please let me know what I am doing wrong?
THANKS!
-Jeff
P.S. Additionally I found that negative values with temperature units requires parentheses.
Hey I ran into similar before. For one reason or another the built in if() does not work in programming when cases() from plugins does, see attached.
I feel this is a bug, but I would wait for more knowledgeable members to chime in.
P.S.: cases() is more flexible version of if() anyway.
In regards to negative temperature value you more or less answered it yourself. In first case you applied "C" unit to 196 only, while in the second case you have applied unit "C" to (-196). Smath Studio does not differentiate between "-" as an operator and "-" as a sign, so units are applied to the previous number 196 only, unless you force it otherwise. You can actually clearly see to which expression you are applying units if you keep pressing right arrow before you press ' to apply units.
WhatAmIDoingWrongSOLVED.sm (11 КиБ) скачан 48 раз(а).

Alex, thank you, I think the cases() function will allow me to work around the issue (with if-else).
I think most of you understand the the problem I presented, but let me try and clarify.
EXAMPLE THAT WORKS AS EXPECTED
Any function containing one or more "NORMAL" MATH FUNCTIONS, can be passed to another function without error.
EXAMPLES THAT PRODUCE UNEXPECTED RESULTS
Any function containing ANY PROGRAMMING CONSTRUCTS, fails to function, or causes an error, when passed to another function.
I'd also just like to add that this one EXCELLENT piece of software! The units handling is a fantastic feature! SO MUCH easier to do engineering calculations than with Excel!
Best regards,
-Jeff
I'm not sure about what you are trying to do.
(xb,x≤c,x≥d) ... semiconstrained is generally adequate
for plotting. In other instances must complete (x≤a,x≥b).
In other instances must be bolean ...
Test(x,y):=(y+y1(x)≥0)*(y-y1(x)≤0)
Jean
Maths 2D Plot Constrained.sm (9 КиБ) скачан 47 раз(а).
Inst_Segment Partial Random.sm (38 КиБ) скачан 39 раз(а).
combined in bolean.
Jean
Maths 2D Plot Constrained.sm (21 КиБ) скачан 47 раз(а).
you see the 1 in the x,y definitions
and in the while loop, they are not subscript
they are index to explode Random in vector.
Here is what I was trying to do. I was evaluating SMath Studio using an example I had implemented in other software (the equation for a Platinum RTD and its inverse using Newton-Raphson). I was only sharing my findings of what I *THOUGHT* should work, but didn't. My previous posts in this thread were simplified *examples*. They were not intended to show *real math*, only to highlight what I thought might be an issue. I have since learned that there are a few ways I can work around the issue. So, at this point, it is no longer a problem for me.
Since the RTD equations differ for t>0°C and t<0°C I started with an if() statement. But I couldn't seem to pass that to my N-R function, as shown here (with the cases() solution).
I have since found that I could also implement it as shown here.
In the process of preparing this example, I found that NR() is evaluating to 0, unless the if() statement is within a line() block. Here are the tooltip captures.
Here is the file.
CVD.sm (26 КиБ) скачан 52 раз(а).
-Jeff
New England [Maine], that's not far from Drummondville [QC] !
I visited many many times Maine, Vermont ... and many more.
Few things needs be known before the hard work:
0. Van Dusen Callendar is a dead horse.
1. RTD is a primary standard, governed by BIPM [Bureau International des Poids et Mesures].
2. BIPM gives the total range in two polynomial segments because of the low temperature elbow.
3. I still have them somewhere in Mathcad 11. They are in the public domain otherwise.
4. Being of polynomial format, therefore analytical, easy to solve for Ω from °C lab bath.
The other part of the story is much simpler.
Some years ago, I have published in my Mathcad web site a "very good" RTD formula.
What was not published is the technique behind the "finding". Was done Mathcad 11.
I will be back soon, my Smath RTD needs a bit of better presenation.
Cheers, Jean
Please, visit Pt100 in "Samples" [posted last minute].
Observe 'argument(w,t)' passed in the solver:
Sol(w,t):=solve(argument(w,t)≡0,t,-260,970)
Your request: "Function(s) as Argument"
Jean
I removed any if() statements used in my programs and replaced with cases(). The issues seemed to resolve themselves.
Edit: I'm using 0.98.6128.10018
I don't understand what you are trying to do vs PT100 formulas.
Either formula I gave or from BIPM. AFAIU, you are trying to
inverse [solve] a discontinuous function. That is not native
in Smath older versions for which solvers don't take "if".
I'm not arguing that "cases" might do.
This is as far as I can help from what I understand.
Jean
Inst_Pt100 [VDC].sm (16 КиБ) скачан 40 раз(а).
Strictly speaking " Functions as arguments" ...
in "2D Bar Stem More.sm", observe in the first
collapsed area ... observe the last argument
Bar:=Stem(p), calling two first functions as
arguments [Smath is delighted doing !].
Jean
Inst_Pt100 [VDC].sm (22 КиБ) скачан 41 раз(а).
2D BarStem MORE.sm (90 КиБ) скачан 40 раз(а).
Observe the dramatic error of VDC at NEGPt100(BIPM=-259.3467)=-7.86 !!!
Jean
-
Новые сообщения
-
Нет новых сообщений