cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

I have some questions about 'LOOP'

jlee-2
1-Newbie

I have some questions about 'LOOP'

I am a korean so I can't write well about my questions. But I will try to write.

I want to express 'Loop'.

Let's we suppose two equations. One is X=Y^2+2Y+3. The last is Y=X^2+3X+5.

I can find adequate value by finding convergence between X and Y.

But I can't express in MATHCAD.

I think I need to use 'While' to express..

How can I express it to use 'while'?

12 REPLIES 12
Werner_E
24-Ruby V
(To:jlee-2)

jinsuk Lee wrote:

I am a korean so I can't write well about my questions. But I will try to write.

I want to express 'Loop'.

Let's we suppose two equations. One is X=Y^2+2Y+3. The last is Y=X^2+3X+5.

I can find adequate value by finding convergence between X and Y.

But I can't express in MATHCAD.

I think I need to use 'While' to express..

How can I express it to use 'while'?

I am not sure what you want to do with loops here.

You have a system of equations and this system has no real solution. You can see this if you substitute the second equation in the first,get an equation of fourth order and plot it.

Mathcad offers a way to minimize the error, maybe thats what you ar looking for:

1.png

For future questions always please attach a worksheet with the expressions in question.

MikeArmstrong
5-Regular Member
(To:jlee-2)

As Werner, I am also a little unsure what you want to do here.

Please provide a worksheet and expected results for us to work with.

Thank you for consideration.

I attached my file. I want to find a2 value when I randomly input a1 values.

But I don't know how I can express 'loop' to solve this problem.

Werner_E
24-Ruby V
(To:jlee-2)

jinsuk Lee wrote:

Thank you for consideration.

I attached my file. I want to find a2 value when I randomly input a1 values.

You have already achieved exactly that in the file you posted!

But I don't know how I can express 'loop' to solve this problem.

For the problem you described above you don't need any loops at all - you have already solved it. So it seems to me you are looking for something completely different. I am not sure if its the peak value as I suspected in my other reply below today.

In the program fragment you provide you don't use a2(a) at all. It looks like you are searching a value of a so that a=f(a) ???

I already asked you in a reply yesterday if you are looking for a=a2(a) and also provided the solution.

So for us to be able to help you must tell us what you are looking for (and not how you think you can achieve that goal). What should the result look like and what should be its characteristics?

BTW, if you write f(a) <-- a in a program you define a local function and you don't assign any values.

jlee-2
1-Newbie
(To:jlee-2)

K-36.png

I am sorry that I made you feel difficult when you saw my post.

I want to know a2 value. To know a2 value, I must know f(a1) value and I also must know a1 value to know f(a1).

it means that I must know a1 value first. so If I assume that a1 value is 0<a1<1, I can know f(a1) by doing iteration. I can know a2 value by comparing a1 value that I input.

But I can't express my thinking in mathcad.

< N=3, lamda_design=7.5 >

Werner_E
24-Ruby V
(To:jlee-2)

As Mike and myself already have writen - attach your worksheet, not just a picture. The willingness to retype what you have already typed is very limited.

Whats the goal of your iteration? When will it stop? Are you searching for a1=a2? This would result in a=0.333333333307379......

Otherwise a2 simply is a function of a1 and you can calculate a2 very easily if you switch the order of the two expressions and use a normal assignment instead of a local one.

I attach my file.

I want to know a1=a2 when I input randomly a1 values to do convergence.

Thank you for your help

< you can see my question in tap of practice2

Werner_E
24-Ruby V
(To:jlee-2)

jinsuk Lee wrote:

I attach my file.

I want to know a1=a2 when I input randomly a1 values to do convergence.

What convergence????

You already have setup a2 which you called b now as a function of a.

What do you expect as a result when you use those loops you are talking about all the time??

Take a look, here is what your function b(a) looks like:

1.png

Here is a magnified view of the peak region around a=1:

2.png

So what are you looking for?? The peak value when a approaches 1? You can get it using the symbolics:

3.png

But you will only get this exact result, if you change 7.5 to 75/10 and 0.1 to 1/10, otherwise you will see 0.333333333333... Thats a very nasty "feature" of Mathcad/Prime since they changed the symbolic engine from Maple to muPad.

I am very thank you for reading my questions.

I attache my file to know that it is rignt.

I think if you see my file, you can understand my question.

thank you

Werner_E
24-Ruby V
(To:jlee-2)

I attache my file to know that it is rignt.

I think if you see my file, you can understand my question.

Unfortunately not.

All I can think of (but I already asked that question twice) is that you search an a1 so that a1=a2(a1).

If yes you should use a solve block:

1.png

Thank you for consideration.

I finally finish my question.

when I solve my question, it is vey helpful to help me althought you don't understand my question.

I am sorry to confuse you becasue my english skill is poor.

Anyway, thank you again.

Werner_E
24-Ruby V
(To:jlee-2)

jinsuk Lee wrote:

Thank you for consideration.

I finally finish my question.

when I solve my question, it is vey helpful to help me althought you don't understand my question.

I am sorry to confuse you becasue my english skill is poor.

Anyway, thank you again.

Yes, language barriers can be very uncomfortable and cumbersome. Not sure if Google translate would be of help.

Anyway, the solve block I showed in my last post does the very same as your iteration routine, but with a much better precision.

You can also use Mathcad's root() function to do the job,

BTW, there are two lines in your routine which have no effect and can be deleted.

1.png

Top Tags