×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

MathCAD While Loop

MathCAD While Loop

MathCAD While Loop

(OP)
I'm trying to get a very simple example started used the Kepler Equation, E = M + e sin E, which is an iterative solution set given M and e as constants.

So I guess E and compute the right hand side, thus generating E' on the left.  This would then feed into E on the right and I would recompute E'.  Usually I have a set point for loop exit as the difference between E' and E as a neglegibly small number, 0.00001.

I can't understand the syntax to MathCAD14.  Any ideas?

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

RE: MathCAD While Loop

Hi Kenneth, you'd be better off in the Mathcad forum. Anyway,

M:21
e:4
E:21 "That's a guess

root( M+e*sin(E)-E,E)=

gives you the normal way of solving it. I'll leave the users of the new improved Mathcad (sarcasm intended) to answer your loops question.

 

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies  http://eng-tips.com/market.cfm?

RE: MathCAD While Loop

M := something
e := something
E := your guess value

Given

E <CTRL>= M + e*sin(E)

Find(E)=

Unless you're purposely wanting to solve it manually, in which case you'll need to create program loop.  

But it's generally more complicated than your sketchup in your OP, since you essentially need to implement Newton's method, and iterate to find a point on the opposite side of the actual solution, and then iterate down to the solution within the tolerance.  The selection and variation of step size as you hunt around the solution and close in is relatively non-trivial.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

RE: MathCAD While Loop

Oh, sorry, didn't explain.  The bit at the front is called a Given-Find Solve Block.  It's not unlike the Excel Solver, and it iterates on its own to find a solution.  Unless you are looking to practice programming, there's generally no need to write your own solver.  Greg's approach is likewise a self-iterating algorithm.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

RE: MathCAD While Loop

In the case of the equation in question there is a bit of a problem with various values of M and e. With appropriate choices there can be anywhere between 0 and infinite roots. So any 'blind' algorithm is going to have to be pretty clever if it is going to find all of them. I'm guessing e is usually -1<e<1, in reality.

IRStuff, is there any advantage in using a Solve block instead of root in this case?

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies  http://eng-tips.com/market.cfm?

RE: MathCAD While Loop

root is probably more general purpose, as it has the ability to limit the range of the solution, however, I think that Find allows you a variety of strategies for finding the solution, e.g, Levenberg-Marquant, conjugate gradient, etc.

Ken,

As always, you should plot the function so that you can get a visual on where the solutions should be expected.  In Greg's example there are 3 possible solutions, requiring 3 different guess values to find the exact values.  Now, that's something you could possibly place into a FOR loop, iterating through different guess values of E to find unique solutions.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

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!


Resources