×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Simple programing to recognize "negative solution"

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.

RE: Simple programing to recognize "negative solution"

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"

RE: Simple programing to recognize "negative solution"

(OP)
I dont understand you well sad
Can you explain a bit more.
Thank you,

RE: Simple programing to recognize "negative solution"

(OP)
Think Ive got it winky smile

RE: Simple programing to recognize "negative solution"

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"

RE: Simple programing to recognize "negative solution"

(OP)
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?

RE: Simple programing to recognize "negative solution"

(OP)
Damn.
Im trying this also with an "on error" statement when the x value is not within the limits but it still doesnt work sad

RE: Simple programing to recognize "negative solution"

(OP)
Plase read my previous post more carefuly.
------> "greater then 8"

RE: Simple programing to recognize "negative solution"

(OP)
Sir,
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"

(OP)
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.

RE: Simple programing to recognize "negative solution"

(OP)
Solved! smile
Thanx!

RE: Simple programing to recognize "negative solution"

(OP)
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?

RE: Simple programing to recognize "negative solution"

(OP)
Hi!
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"

It doesn't need to be on the last line, it just needs to have been assigned and not over-written, and it needs to still be running the program.

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"

(OP)
@IRstuff
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"

Quote (mar2805)

How did you use these scriptable components?
Basically yes. The specific here was copied from another sheet of mine and then the VB code edited to fit your needs.

RE: Simple programing to recognize "negative solution"

@mar2805: Sorry, I missed your ???'s

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close