Rank: Newbie
Groups: Registered
Joined: 01/11/2016(UTC) Posts: 5 Location: New England
|
I 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 (10kb) downloaded 61 time(s).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.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Smath shhould do what you want. 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 (18kb) downloaded 47 time(s).
|
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
Originally Posted by: Jeff Butler I 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 (10kb) downloaded 61 time(s).Would someone please let me know what I am doing wrong? THANKS! -Jeff Hello Jeff, I think this might be a bug Regards, Radovan |
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 03/03/2014(UTC) Posts: 418 Was thanked: 125 time(s) in 96 post(s)
|
Originally Posted by: Jeff Butler I 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 (10kb) downloaded 61 time(s).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 (12kb) downloaded 33 time(s).Edited by user 02 November 2016 02:41:50(UTC)
| Reason: Not specified
|
2 users thanked Alex M. for this useful post.
|
on 02/11/2016(UTC), on 02/11/2016(UTC)
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Your construction looks in conflict
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,639 Location: Italy Was thanked: 1323 time(s) in 873 post(s)
|
I guess the problem is that Function1() throws an error while his arguments are proprocessed to be passed to the procedure (possible fix: skip the exceptions at this level, if it is consistant). I'll move this topic in bug & problems, though. |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 01/11/2016(UTC) Posts: 5 Location: New England
|
Thank you all for your input. 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
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Jeff, I'm not sure about what you are trying to do. (x<a,x>b,x≤c,x≥d) ... semiconstrained is generally adequate for plotting. In other instances must complete (x≤a,x≥ . In other instances must be bolean ... Test(x,y):=(y+y1(x)≥0)*(y-y1(x)≤0) Jean Maths 2D Plot Constrained.sm (10kb) downloaded 24 time(s). Inst_Segment Partial Random.sm (39kb) downloaded 25 time(s).
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Note: in the function Pts 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.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 01/11/2016(UTC) Posts: 5 Location: New England
|
Hi Jean, 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 (27kb) downloaded 37 time(s).-Jeff
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Hello 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
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Jeff,
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
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/03/2016(UTC) Posts: 275 Was thanked: 91 time(s) in 57 post(s)
|
I was also having some strange issues with my programs that passed functions. Specifically really strange behavior with using ranges in the el() function. However, submatrix() worked just fine. I also had some issues with vectorization. If i tried performing a function within the program, I would receive an error. However, if the program returned the input to the function and I used the same call outside of the program, it worked fine. 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 Edited by user 22 November 2016 23:48:12(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
Hello, Jeff 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 (17kb) downloaded 25 time(s).
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
This document includes solving both VDC segments. 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 (23kb) downloaded 31 time(s). 2D BarStem MORE.sm (91kb) downloaded 29 time(s).
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,868 Was thanked: 980 time(s) in 808 post(s)
|
... in VDC: move the positive segment a bit down to clear the 1rst dichotomy. Observe the dramatic error of VDC at NEGPt100(BIPM=-259.3467)=-7.86 !!!
Jean
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.