Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple programing to recognize "negative solution"

Status
Not open for further replies.

mar2805

Structural
Dec 21, 2008
375
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.
 
Replies continue below

Recommended for you

you could do an If statement that checks (a-b) < |a-b| (or whatever is inside your rood) then don't do the root.

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"
 
I dont understand you well :-(
Can you explain a bit more.
Thank you,
 
if((b2-4ac)<0,"",sqrt(b2-4ac)) as an example

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
This is the MathCad forum right?

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"
 
Seem that Ive hit another problem.
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?
 
Damn.
Im trying this also with an "on error" statement when the x value is not within the limits but it still doesnt work :-(
 
?? Your program returns "greater than 5" already??

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Plase read my previous post more carefuly.
------> "greater then 8"
 
So, change the if statement so that it checks for >8??? I would have thought that was an obvious thing to change, hence my presumption that there was something else wrong.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Sir,
please do check your statements before you post them and also try using them first with the files I previously attached.
Thank you.
 
Yes it work out side the programing line, but how to make it work inside the programing lines (my previous attached file)?
Thats the problem.
 
Hmmmmmmmm...
This is very interesting.
You are truly an advanced Mathcad user.
Thank you!
Can plase explain the 1+1 condition in you statement. Why?
 
That was just to force the program flow so that it would process the "on error" before the "return."

Actually, I don't do programming much at all.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor