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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Translate the entire conversation x

How to get a argument out of a optimisation (maximize) function

andreas_lanter
5-Regular Member

How to get a argument out of a optimisation (maximize) function

Hello

I hope somebody could help me.

I have this function with a table which shows the "a_hoch" and "a_lang" values. I want to show the angle "alpha" as well in this table. How could I do this? Unfortunately I can not upload the file.

andreas_lanter_0-1765534270621.png

andreas_lanter_1-1765534292948.png

 

Thanks a lot and best regards

Andreas

 

12 REPLIES 12

Hi Andreas

You did not say but assumed Prime 11

Capture.JPG

Capture2.JPG

Cheers

Terry

Hi Terry
Sorry I use Prime 7. Tried to implement your formula but get strange alpha values.

andreas_lanter_0-1765547231622.png

 

Sorry but I can not upload my file.

Could you help me again?

Thanks a lot!

Hi Terry

Mabe I can send you me file via mail.

Regards

Andreas

The forum still has troubles with attachments. It will refuse to attach Mathcad and Prime files. Curious enough it seems to work OK for some users like Terry, but not for users like you and me. (@AndrewK : Are there any news on this from Khoros?)

As other files like pdf's or zip's work OK, the workaround is to put the file in an archive (zip, rar, ...) and attach that archive file.

 

I am confused as your problem seems to be the same as was posted here and it looks like you took my suggestion for creating a table from there. Unfortunately you still stick to the time consuming "a_l" function which is three time slower than necessary.

 

I notice that the second equation in your solve block differs from the one given in the thread referenced. You used "(D-d)" while @PL_14431742  had used just "D".

 

According your angles being that different compared to ones shown by Terry the only explanation which comes to my mind is that you are using different Prime versions and maybe the numeric algorithm used by "maximize" had changed. Actually the results you get are correct, too, given the periodicity of the sine and cosine functions. You get Terry's values for the first few entries if you add 30 time 2 pi.

 

Even in Prime 11 the angle values we get for alpha run from -15.5 up to 84.6.

Werner_E_0-1765553271121.png

 

You could add an additional constraint like   0<=alpha<=2 pi  in the solve block but this would make the solve block fail now and then for some values of a_hoch. It might be a good idea to use a "try...onerror..." in the solve block in case maximize can't find a solution for one reason or another:

Werner_E_2-1765553828196.png

 

A better approach for the angle correction might be to correct the angles after they were calculated by the solve block.

Here is a function which works four time faster than what was shown so far and it returns not only alpha, but also the value of alpha corrected to be in the range from 0 to 2 pi and it also provides the angle values ta and ta.

The parameter "a"of this function is a vector of a_hoch values.

Werner_E_1-1765553673673.png

Werner_E_3-1765553900644.png

 

If you compare the angles in alpha_corr with the ones in alpha you can see that they all lie in the range from 0 to 2pi, but we don't get a continuous curve if we plot them over a_hoch. Not sure if this is to be expected.

Werner_E_4-1765553996300.png

This on contrary to "a_lang" which makes a nice continuous curve

Werner_E_5-1765554253127.png

Angles ta and tb also show extreme values

Werner_E_0-1765554648718.png

Once we apply a similar correction as with alpha it looks like this:

Werner_E_1-1765554724971.png

 

 

AndrewK
Community Manager
(To:Werner_E)

Hi @Werner_E Khoros says the issue is fully resolved so I will let them know some users are still seeing the issue. In the meantime, I posted about it here along with your workaround. Thanks!

Werner_E
25-Diamond I
(To:AndrewK)

We had a similar problem with mcdx, xmcd, mcd and xmcdz files in the past when the forum switched over to Khoros. The problem took quite long to resolve and it was necessary to archive the files to be able to attach them for a long time :-(.
In the past we got an error message - something about an invalid file type. But now we don't get any error message at all, the file simply would not be attached.

As far as I remember in the past some people were able to attach files directly, too. Can't really remember in detail but I think it had something to do with registry entries in the Windows installation of the user! You may be able to find some threads  dealing with the problem from that time.

Thanks for caring!

BTW, I would have expected the information in "Announcements", not in "Feedback". 😉
But maybe it would be a good idea to have a separate section "Current News" for informations of this kind (also expected downtime due to planned maintenance, etc.)

andreas_lanter
5-Regular Member
(To:Werner_E)

Hi Werner_E
Thanks for your answer. Have to look deeper into this problem.
I attached now the file as zip.
Maybe you or Terry could implement the solution to get the alpha values directly into my file. This would help a lot.
Thanks and best regards

Andreas

I don't have Prime 7 installed, so you will have to retype from the pictures sent.

What do you see when you evaluate MAX(365)?

In Prime 11 I get using the sheet you posted

Werner_E_0-1765555966713.png

 

Find attached a pdf print of the file I used.

 

Werner_E
25-Diamond I
(To:Werner_E)

I just opened your file in Prime 10 and also in Prime 9 (the oldest full version I have installed) and can say that the underlying numeric algorithm sure has been changed when going from P9 to P10.

Prime 10 shows the very same results as shown above with Prime 11.

But the results in Prime 9 (again just using your sheet) are completely different:

Werner_E_0-1765594704036.png

Nonetheless the results are correct and lead to the very same value of a_lang.

 

Werner_E
25-Diamond I
(To:Werner_E)

I continued playing with the (P11) sheet and tried to get continuous values for the three angled involved.

In a first step I turned the solve block into a function with the three guesses as additional arguments:

Werner_E_1-1765595809410.png

Then I modified my "makeData" function so that it uses your initial guesses just for the first value calculated and after that uses the results of the previous calculation as guess values for the next one. Doing so makes the solve block fail already for the second value (366). A bold fix was to add a small amount (0,001) to the alpha guess (not sure why this cured the problem.

Werner_E_2-1765595980843.png

 

These modifications resulted in nice continuos angle values (in Prime 11)

Werner_E_3-1765596064364.png

which of course is also shown in the plots (without any need to force the results to the interval [0; 2 pi).

Werner_E_4-1765596153029.png

 

You may try in your Prime 7 if you can find initial guess values (maybe using values close to the ones seen in th efirst row of the table shown above) which give you the same results for MAX(365) as I had shown in Prime 11.

 

Prime 11 file attached, for whatever it may be worth (maybe someone is able and willing to convert it into P7 format for you)

EDIT: Arggh! Forgot to zip the file. Annoying! Hope the forum bug will be fixed soon.

 

Curious enough it seems to work OK for some users like Terry, but not for users like you and me. 

 

I could not use the browse button on the attachment area, but could use drag and drop!

Cheers

Terry

Hmm, mysterious! I tried both and none worked. No error message, just the file is not showing up.
Only Mathcad and Prime files are affected, PDF's and archive files work OK.

We had a very similar problem (also Mathcad and Prime files and also with some users being able to upload) some years ago when the forum software was migrated to Khoros. I sincerely hope that this time it won't take as long as it did back then to resolve the issue.

Announcements

Top Tags