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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Non-linear system of equations with variable number of equation

gfryns
1-Newbie

Non-linear system of equations with variable number of equation

 

Dear Mathcad Helper,

As shown in the attached sheet, I am trying to solve a non-linear system with 2N+5 equations.  Among the 2N+5 equations, there are N+1 equations for one type of conditions, N+1 equation for another type of conditions and 3 individual separate equations.

 

The number of unknowns is 2N+5.  The unknowns are grouped in one (N+1)-vector, one N-vector and another 3 separate unknowns.

Here are two questions:

  1. Is there a way to use correctly the range variable “i” in order to formulate in a compact manner the two types of conditions?  I have difficulties with the range variable “i”.
  2. Is the regrouping of unknowns within multiple separate arrays (i.e. B and η) legal within a Find function?  If not, what would be a nice solution?

  

Note:   So far, the only one way I have been able to solve (partially) the non-linear equation system is to defined N as a single integer value, to explicitly write all 2N+5 equations one by one, and to use explicitly all 2N+5 unknowns.

Thank you for your interest and comments,

 

Gery

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

" The function fX that you suggested might not be that easy to formulate with separate i and j values."

This is not difficult.  The attached shows how.  It solves for 7 values of B, 8 values of eta, and a single value for F, G and k.  It uses a fixed value of c.  If you want c to float as well you need to specify another independent equation.

Alan

View solution in original post

19 REPLIES 19

See please my try to use i:=1...N in the block Given....

Three questions to the Solve-block

LucMeekes
23-Emerald III
(To:gfryns)

Independently of the indexing, you should carefully check your equations.

The last equation in the solve block defines c as a function of 2, pi, k and T, while T is given as a constant.

That means that c can be calculated as soon as (only!) k is known, it means c is not independent of k, this equation is not independent and does not help (rather interferes) with finding your solution.

Success!

Luc

Luc,

You are right.  The Mathcad worksheet version I published is a trimmed down version.  Indeed, I could have remove one extra unknown of the problem in order to facilitate Mathcad work.  However, the stated problem was correct, was it not?

Thank you for your comment.

Gery

LucMeekes
23-Emerald III
(To:gfryns)

Then I find that you've put the entire stuff in a single text block. While that may work (... I don't think it will), I strongly suggest you take it apart in separate text blocks and equations.

Success!
Luc

Luc,

Yes, this is an habit I developed a long time ago: work in one single text region and use Ctrl-Shift A to add equations.  I like to develop my Mathcad sheet with the final report in mind and to keep record of the thought process.  (The Mathcad worksheet version is a trimmed down version.)  The transfer of a Mathcad text region to MS Wordand the implementation of MS Word Style are straightforward.  I convinced several people to try and use this method.  They are still using it!  Yes, I have an "Internal Error" from time to time and I have to refresh the sheet by cutting and pasting back the entire text region.

I will  mention it in the original question from now on.

I never worked with Prime.  I would be interest to see if there is any additional usefull format and export features.

Thank you for your comment,

Gery

Hi Guery.

Attached is in one of the corrects paths, but have an issue for continue, which is that in that way you have 6 unknouns and 5 equations. The attached don't take all the equations at the same time, but at least take them one by one, thus can be used for some other iterative precess.

I'm courious about two things: As Luc Mentions, your style isn't the usual, and your naming style, too.

Best regards.

Alvaro.

Hi Alvari,

Before to look at an interative solution, I really wanted to resolve the problem in a similar fashion than what I showed in my original email.  In that respect Allen provide me with the prefered direction.

At the end, the problem, I am working with will be an iterative solution.

Thank you for trying.

Gery

See if the attached helps.

Alan

Alan,

Thank you for your elaborated response.  It is almost correct!  F and G are constant.  The result in 160828 Matcad b.xmcd.zip show a vector matrix for F and G with different element results.  All elements must be equal in F and G, respectively.  I tried very rapidly a few things by adding constraints in the block without success.  I will get back to it later.

Thank you for your help.

Gery

PS: See my attempt based on your files: it does not work.

I've now looked at this a little more closely.  The only way the B terms enter the equations is as a sum over all its elements.  This means the individual components, as found by Mathcad, have no real meaning.  Only the sum has meaning, so one might as well replace the sum over j of Bj by the single scalar B.  This is what I've done in the attached.  The results change a little (as they do for different initial guesses for B).


(Note: the individual i terms involving the sinh's cosh's etc. are completely independent of the Bj's).

Alan

Hi Allan,

Thank you for your interest.  I must apologize: there is a mistake in my initial questions.  (I thought that I was able to correct it and resave it but I realized that the correction I made did not take effect.)  The sentence regarding the unknows should read:

"The number of unknowns is 2N+5.  The unknowns are grouped in one (N+1)-vector (h), one N-vector (B) and another 4 separate unknowns."

Again, B is a vector with N unknowns.

Allan Steven (Aug 28, 2016 1:24 PM) proposed a solution, which is almost correct.  The only issue is that  F must be a single constant (or an (N+1) vector with all equal elements), and that G must be a single constant as well (or an (N+1) array with all equal elements).

Again, thank you for your attempt.

Gery

 

Gery Fryns wrote:

Hi Allan,

Thank you for your interest.  I must apologize: there is a mistake in my initial questions.  (I thought that I was able to correct it and resave it but I realized that the correction I made did not take effect.)  The sentence regarding the unknows should read:

"The number of unknowns is 2N+5.  The unknowns are grouped in one (N+1)-vector (h), one N-vector (B) and another 4 separate unknowns."

Again, B is a vector with N unknowns.

Allan Steven (Aug 28, 2016 1:24 PM) proposed a solution, which is almost correct.  The only issue is that  F must be a single constant (or an (N+1) vector with all equal elements), and that G must be a single constant as well (or an (N+1) array with all equal elements).

Again, thank you for your attempt.

Gery

 

Have you set up your equations correctly?  Your B occurs only as a sum over its elements, as the other terms that seem to multiply Bj are independent of j.  They therefore come outside of the summation over j and, in effect, you are left with a single value for B (the sum of its elements), so this reduces to a single unknown. 

Your unknowns are therefore: 1*B + 8*eta + 1*F + 1*G + 1*c + 1*k   i.e. 13 unknowns. 

But you have 19 equations:  8 for the first equation in the solve block, 8 for the second, and 3 singles.

Alan

Alan,

Yes, you are right, the equations are not set up correctly: i and j are mixed up.  Thank you for making me think differently!

I am busy on other 'stuff' and it might take a few days.  If I still have problems, I will present the problem in a mathematical form, not as a Mathcad problem.  The function fX that you suggested might not be that easy to formulate with separate i and j values.  All i must be changed to j, except for eta in all 2(N+1) conditions.  I will let you know.

Thank you, (this is a big help since I am working in isolation.)

Gery

" The function fX that you suggested might not be that easy to formulate with separate i and j values."

This is not difficult.  The attached shows how.  It solves for 7 values of B, 8 values of eta, and a single value for F, G and k.  It uses a fixed value of c.  If you want c to float as well you need to specify another independent equation.

Alan

 

Hi Alan,

 

Thank you again for your interest.  Your first reply showed me the way forward and convinced me that it will work.  Also, it pointed to me that there was a few mistakes in my development.

 

Thank you for your last email and I would like to make the following comments:

    • Definitely, there is a way to develop a system with a variable N number of equatio
    • The c^2 tells me that I still need to check a few things
    • You reduced the number of unknown.  That is OK, but I do not think that it is the real issue.

The first Mathcad (i.e. Mathcad1) sheet shows the long hand development. It works and give me “an” answer. (I will check the c^2 thing and make sure my dimension are lined up.  The second Mathcad sheet (i.e. Mathcad2) attempt to duplicate the results by using the array the way you showed me in your first email.  It looks like I am almost there but there is still a bug.  With the work you have done in your last email, it might be easy to identify it.

 

I will not have access to Mathcad for the next two weeks starting this Friday. Anyway, the “Correct Answer” is almost there.

 

Thank you.

 

Gery

 

gfryns
1-Newbie
(To:gfryns)

Allen,

The Mathcad3 worksheet works.  I used the same functions that you proposed.  I kept the 2N+5 equations/unknowns.  The results are comparable with the Mathcad1 sheet but not exactly the same.  I will investigate.

I noticed that for some values, I must go to Tools/Worksheet Option, Calculation Tab and untick the second box.  I might have to adjust the Convergence (TOL) and Restraint Tolelances (CTOL)  under the As-built Variable.  If you could direct me to a discussion on this subject, it would be very nice.

I still wonder why the Mathcad2 worksheet does not work!

The purpose of my original question is now answered.  Again, Thank you.

Gery

I've now got the Mathcad2 sheet working - see attached.

The problem was the multiplication of two vectors inside the summations.  They were being multiplied as true vector multiplications, resulting in a scalar.  They need to be multiplied element by element.  (I should have caught this sooner - my apologies!).

Mathcad2b now gives same results as Mathcad1.

Alan

Great Allen!

It has been a productive leaning curve for me and enjoyable!

Thank you.

Gery

My attachment Mathcad3 was not correct.  Here is the good one.  Apologies.

Top Tags