Simple programing to recognize "negative solution"
Simple programing to recognize "negative solution"
(OP)
Hi folks!
Somethnig Im trying to do but simply cannot find the solution.
Few questions.
I have an quadriatic equation wich sometimes creates negative number under the root expression.
I would like Mathcad to write an expression when this happens.
I tried doing this with simple programing.
Basicly what I did is add to lines with two conditions:
1st) "NOT AVAILABLE" if .................... (this is where I get lost, how to tell him when you get negative number under the squareroot?)
2nd) "AVAILABLE" otherwise
Is it possible to hide the function (expression) for wich you are finding the solution.
Like in previous egsample X:= two mentioned programing lines
Wich would finaly give X = something
How to hide "X=" so that you only see the result?
When using programing lines is it possible to define two action for one conditions and one action for the second condition?
Egsample if I have equation x-3=0
II"AVAILABE" I
II I if x>0
II"X=5" I
I "Not available" othervise
So basicly if x gives soution >0 I would like Mathcad to report an "AVAILABE" comment and give the solution x=5
Any chance for something like this?
Thank you.
Somethnig Im trying to do but simply cannot find the solution.
Few questions.
I have an quadriatic equation wich sometimes creates negative number under the root expression.
I would like Mathcad to write an expression when this happens.
I tried doing this with simple programing.
Basicly what I did is add to lines with two conditions:
1st) "NOT AVAILABLE" if .................... (this is where I get lost, how to tell him when you get negative number under the squareroot?)
2nd) "AVAILABLE" otherwise
Is it possible to hide the function (expression) for wich you are finding the solution.
Like in previous egsample X:= two mentioned programing lines
Wich would finaly give X = something
How to hide "X=" so that you only see the result?
When using programing lines is it possible to define two action for one conditions and one action for the second condition?
Egsample if I have equation x-3=0
II"AVAILABE" I
II I if x>0
II"X=5" I
I "Not available" othervise
So basicly if x gives soution >0 I would like Mathcad to report an "AVAILABE" comment and give the solution x=5
Any chance for something like this?
Thank you.





RE: Simple programing to recognize "negative solution"
David Simpson, PE
MuleShoe Engineering
"Belief" is the acceptance of an hypotheses in the absence of data.
"Prejudice" is having an opinion not supported by the preponderance of the data.
"Knowledge" is only found through the accumulation and analysis of data.
The plural of anecdote is not "data"
RE: Simple programing to recognize "negative solution"
Can you explain a bit more.
Thank you,
RE: Simple programing to recognize "negative solution"
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Simple programing to recognize "negative solution"
RE: Simple programing to recognize "negative solution"
David Simpson, PE
MuleShoe Engineering
"Belief" is the acceptance of an hypotheses in the absence of data.
"Prejudice" is having an opinion not supported by the preponderance of the data.
"Knowledge" is only found through the accumulation and analysis of data.
The plural of anecdote is not "data"
RE: Simple programing to recognize "negative solution"
I have a function called
Nos(x1)=some quadriatic equation
Using the "root function" I want to find the solution for x1
x1:=root(Nos(x),x,0,h)=
Later in the worksheet I made an simple programing involving the value x1 wich basicly says when to use x1 value and when to not use
it.
But once the x1 value becomes unavailable (its not within the limits "0 and h", negative number under the square root appears) Mathcad simply ignores all other programing statements and just marks the x in RED saying that the variable is not defined.
I tried puting the statments that involves "x1" to the end of the programin line and even used RETURN operation on previous statments but it seems that if the x1 doesnt have some real solution it just blocks the programing line.
Can this programing line somehow work eventhou "x1" doesnt have any solution in defined limits?
RE: Simple programing to recognize "negative solution"
Im trying this also with an "on error" statement when the x value is not within the limits but it still doesnt work
RE: Simple programing to recognize "negative solution"
Basicly what I want is to get an comment "greater then 8" when theres no solution found within the limits 0 and 8.
Any ideas?
RE: Simple programing to recognize "negative solution"
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Simple programing to recognize "negative solution"
------> "greater then 8"
RE: Simple programing to recognize "negative solution"
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Simple programing to recognize "negative solution"
please do check your statements before you post them and also try using them first with the files I previously attached.
Thank you.
RE: Simple programing to recognize "negative solution"
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Simple programing to recognize "negative solution"
Thats the problem.
RE: Simple programing to recognize "negative solution"
Thanx!
RE: Simple programing to recognize "negative solution"
Why it doesnt say now "greater then 5".
It just show the number?!
RE: Simple programing to recognize "negative solution"
http://files.engineering.com/getfile.aspx?folder=3...
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Simple programing to recognize "negative solution"
This is very interesting.
You are truly an advanced Mathcad user.
Thank you!
Can plase explain the 1+1 condition in you statement. Why?
RE: Simple programing to recognize "negative solution"
Actually, I don't do programming much at all.
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Simple programing to recognize "negative solution"
Heres the same solution (thanx to you) in another way.
But I dont understand how can MATHCAD calculate z value thats "under 5" if I didnt define the last programing line as "x1"?
Its seems that it went thru the last condition "greater then 5" if root(........)>5" saw that its not valid and anyway calculated the value.
On the other hand if I put 3rd programing statement as "x1" as soon my root equation is not vaild it returns error.
IRstuff whats your opinion?
RE: Simple programing to recognize "negative solution"
As in algebra, order of operations is important, with the additional wrinkle that you have the option of ending the program prematurely. So, you have to pay particular attention to what you've commanded in the logical flow of the program. This is what makes programs so difficult to debug and maintain, which is further compounded by the innate lack of debugging tools in Mathcad.
http://files.engineering.com/getfile.aspx?folder=2...
TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Need help writing a question or understanding a reply? forum1529: Translation Assistance for Engineers
RE: Simple programing to recognize "negative solution"
RE: Simple programing to recognize "negative solution"
RE: Simple programing to recognize "negative solution"
OK, here is a slightly modified/corrected version of the file.
RE: Simple programing to recognize "negative solution"
Thank you very much!
Egsamples you posted where realy helpfull in understanding the importance order when programing with MATHCAD
@rmix22
How did you use these scriptable components?
Insert-> Component-> ???
RE: Simple programing to recognize "negative solution"
RE: Simple programing to recognize "negative solution"
It's: Insert/Control/Text Box
then RightClick - Add InputVariable
then RightClick - Edit script
and off we go using VBScript commands
At last to clean up I chose to Hide Arguments (again RIghtClick)