Why solving Equations not valid for m = 5 and n = 13

  • Thread starter Thread starter kaizen.moto
  • Start date Start date
  • Tags Tags
    Solving equations
AI Thread Summary
The discussion centers on issues encountered while solving equations in Mathematica for specific values of m and n, particularly m = 5 and n = 13, which yield results dependent on other constants rather than definitive values. The user notes that while their code works for m = 1 and n = 1, it fails to provide expected outputs for the larger values, generating warnings about unsolvable variables. Suggestions are made to simplify the problem presentation and to utilize Mathematica's Reap and Sow functions for better result collection. Additionally, it is recommended to compare outputs from both cases to identify discrepancies in the equations being solved. The conversation emphasizes the importance of clarity in code and the impact of software version differences on results.
kaizen.moto
Messages
94
Reaction score
0
Hi everyone,

Iam just wondering on why my codes (with Mathematica) are not valid for the case of m = 5 and n = 13. However, they work perfectly for other cases for example, when m = 1 and n = 1. Note that m = 1,3,5,7,..99 and n = 1,3,5,7,...99.

Please let me know about this matter.

Thanks a lot for any response.
 

Attachments

Last edited:
Physics news on Phys.org
Can you give us any hint about what isn't valid for m=5 and n=13?

Starting fresh and evaluating your notebook for m=1 and n=1 completes with 17 rules for each of Ao and Bo.

Starting fresh and evaluating your notebook for m=5 and n=13 completes with 17 rules for each of Ao and Bo.

There do not appear to be any warning messages about serious errors.

I am being very polite here. Perhaps this will help you with questions you ask in the future. Imagine someone from the other side of the world walks into your office, dumps 100-200 kbytes of source code on your desk, says "I typed some stuff in, some stuff came out, some stuff is wrong, what is it?" You are probably not going to take their 100-200 kbytes of source, read it all, reverse engineer it until you understand what field they are working in, what problem they are working on, how much they know, how much they don't know, what methods they are using, where they have a small misunderstanding or even a misplaced character, and then point that out to them. Or at least you will not do that very many times, not unless there is some superior/subordinate relationship that demands this or unless there is some expectation that the favor will be repaid in the future when you dump 200 kbytes on their desk.

Can you make the kind of problems that you post repeatedly substantially easier for someone who knows absolutely nothing about what is in your head because you have probably been working on your problem many hours a day perhaps for months or years?

Perhaps that will substantially increase the likelihood that you will get helpful replies and be able to get on with the work you need to do.

Because you seem to repeatedly have problems with not getting the same results from Do[] loops, perhaps Reap and Sow might help you. Here is a small example

In[1]:= Reap[Do[i;i^2;Sow[i+3];i-4,{i,1,6}]][[2,1]]
Out[1]= {4,5,6,7,8,9}

The i;i^2 and i-4 are just examples of intermediate results calculated during your Do, but that you are not interested in, what you want is to see the result of i+3 each time.

Reap "creates a bin" that results will be put into in order by Sow. Sow can put any sorts of results in there. The bin just keeps filling until the Do is finished and then the Reap takes all the results and hands them back to you. You can have multiple Sow inside the Do, each with different expressions that you want to collect for output at the end. That [[2,1]] at the end discards some extra information you probably don't need. But the point is that Reap will collect up all the results from Sow, in order, and give them to you as the result.

Perhaps Reap and Sow will let you use the Do loop you have been using and still get the results that you want.
 
Thank you for the response.

First of all, I apologise for sending the question without giving much details and information about what the processes are involved within the codes.

I have re run the codes again for the case of m = 5 and n = 13. I got the following warnings at the final cell:

In[93]: sols=Solve[eqn,{Ao[1],Ao[2],...Bo[17]}]

' Solve::svars: Equations may not give solutions for all "solve" variables.>>

Out[93]: {{Ao[1] -> (-0.000274089 + 0. I) Bo[1] + (9.39803*10^-6 + 0. I) Bo[2] + (0.000764148 + 0. I) Bo[3] + (0.000392242 + 0. I) Bo[4] + (0.00012964 + 0. I) Bo[5] + (0.0000317941 + 0. I) Bo[6] + (5.3972*10^-6 + 0. I) Bo[7] + (1.03385*10^-7 + 0. I) Bo[8] - (4.11587*10^-7 + 0. I) Bo[9] - (2.28213*10^-7 + 0. I) Bo[10] - (8.62241*10^-8 + 0. I) Bo[11] - (2.6323*10^-8 + 0. I) Bo[12] - (6.26092*10^-9 + 0. I) Bo[13] - (1.13728*10^-9 + 0. I) Bo[14] - (3.75834*10^-10 + 0. I) Bo[15] + (1.06291*10^-10 + 0. I) Bo[16] + (2.17232*10^-10 + 0. I) Bo[17] - ((0.0000669681 + 0. I) a q)/Subscript[C, 11],........Ao[17] -> (0.000406024 + 0. I) Bo[1] - (0.000260281 + 0. I) Bo[2] + (0.000614667 + 0. I) Bo[3] + (0.000302377 0. I) Bo[4] + (0.0000883891 + 0. I) Bo[5] + (0.0000160242 + 0. I) Bo[6] + (3.52602*10^-7 + 0. I) Bo[7] - (1.25433*10^-6 + 0. I) Bo[8] - (7.0549*10^-7 + 0. I) Bo[9] - (2.68923*10^-7 + 0. I) Bo[10] - (8.28229*10^-8 + 0. I) Bo[11] - (2.10363*10^-8 + 0. I) Bo[12] - (3.81775*10^-9 + 0. I) Bo[13] - (6.9347*10^-10 + 0. I) Bo[14] - (9.55954*10^-11 + 0. I) Bo[15] - (0.000362862 + 0. I) Bo[16] + (0.000247239 + 0. I) Bo[17] - ((3.11726*10^-7 + 0. I) a q)/Subscript[C, 11]}}.

The above output shows that for every constant Ao[1], Ao[2],Ao[3]....Bo[17] gives the results which comprises of another constants. This shouldn't be the case that I am expected. What Iam looking for is the value of Ao[1], Ao[2] and so on should give a definite result,.i.e. not dependent of other constants.
These definite results for each unknown can be clearly seen for other cases for instance m=1, n=1.

Iam wondering how you managed to get no warnings for the case of m = 5 and n =13. Iam using Mathematica version 7 (windows).
 
I took your original notebook, made a copy of it, did a fresh evaluation of one with m=1,n=1, did a fresh evaluation of the other with m=5,n=13, deleted all the intermediary calculations with the spelling caution messages, but nothing else, and attached each to this. You can open each of those and compare the results.

As you will see, other than the specific numeric coefficients, I get equations of the same form from both.

Even tiny changes in versions of Mathematica can result in substantial changes in behavior, particularly when it is being used in ways that Mathematica did not expect you to use it.

To track down why you are getting different results for the two cases I would suggest you remove the ";" from the end of your next to last line "eqn={Ao[1]+U1==0,...} and save a copy of the (likely very large) output from that line. Do this for both m=1,n=1 and m=5,n=13. Then compare those two outputs. I suspect you will find that somewhere in your 100+kbytes of code that the way you have written this results in a missing or extra variable and that is likely why when you finally invoke Solve that one case gives a result in the form you desire while the other is confused by the different eqn and gives the result that you do not want.

I hope this helps you track down where the discrepancy lies.
 

Attachments

Back
Top