
Like (0)
Hi,
I have a question and need help. Assuming that we have a set of Prime Numbers (from 5 to 37
in this case) Let's extract Twin Primes like as the Output below. (IN .MCD12)
Thanks in advance.
Regards,
Loi.
Something like the attached?
Mike
Sorry, but that's not correct. Twin primes are pairs of primes that differ by 2, so (23,29) is not a valid pair.
Loi Le wrote:
Thanks, Richard. Possibly I should have the updatequestion :
Just a topofthehead thing, but might be worth playing with. Makes use of the fact that 'triple primes' don't exist (unless you count 1,2,3), to avoid retesting numbers.
Stuart
Makes use of the fact that 'triple primes' don't exist (unless you count 1,2,3), to avoid retesting numbers.
Another 10^9 C saving in global warming
Richard Jackson wrote:
Makes use of the fact that 'triple primes' don't exist (unless you count 1,2,3), to avoid retesting numbers.Another 10^9 C saving in global warming
A nanocoulomb? Sorry, guv, I never really got past pounds, shillings and pence. What's that in moles of electrons?
However, you neglected the effects of relativity on subjective time experience ... that' gotta be worth a couple of microseconds of anybody's time!
Stuart
Your answer is very completely to my question. Thanks a lot indeed.
Loi.
Nice function...... Impressed
Was going to propose an alternative, but I don't think I could.
Mike
Mike Armstrong wrote:
Nice function...... Impressed
Was going to propose an alternative, but I don't think I could.
Mike
Oy vey iz mir! Are my lessons forgotten so soon, already?
There's *always* an alternative to anything I suggest
There are a couple of tricks to finding alternatives.
One is to just look at it sniffily and pick holes in it. "Hah! It doesn't handle the (special case) pairs (2,3) & (3,5)!" (having, naturally, extended the prime sequence) and then noting that it doesn't pick up the true prime triplets (2,3,5) & (3,5,7), extend the idea into Prime Constellations  ie, some sequence of primes that spans the minimum distance according to some criteria, eg prime triplets can be of the form (p,p+2,p+6), (p,p+4,p+6), (p,p+6,p+12), etc. Having then sneered at my rather pathetic program, you can then produce the piece de resistance that knocks mine into a cocked hat.
An alternative viewpoint is to, as Jean would have said, draw inspiration from a worksheet by saying "Wow! I wonder if it's possible to extend that program to cover other cases!"; both views can lead to the same result. Depends whether competition is your forte or you have a temperament like a Labrador puppy newly promoted to 2nd Lt.
Or you could be like me, a cross between Scrooge and the Four Yorkshiremen. I were raised when you could count each clock cycle of t' CPU and every bit counted, but you try and tell the young people of today that ..... they won't believe you. So profligate waste, such as Richard's checking a number more than once, that may be acceptable if you've got gigs of RAM and Hz, just offends my sensibilities (well, that's a bit of an exaggeration, I've only got the one sensibility).
Which leads to another way of developing alternatives  take a trick out of Paul Dirac's book and look for the beauty or elegance in a method.
Stuart
Stuart,
After reading your post I thought "I'm not a Labrador puppy" and decided to write a function which would collect Triplet Primes, see below.
Then, I decided to do a little research into types of Prime numbers and realised that there are multiple types.
Which massivly deflated me and made me realsie I might be more of a Poodle than a Labrador
Mike
Mike Armstrong wrote:
Stuart,
After reading your post I thought "I'm not a Labrador puppy" and decided to write a function which would collect Triplet Primes, see below.
Then, I decided to do a little research into types of Prime numbers and realised that there are multiple types.
 Pairs
 Triplets
 Quadruplets
 Quintuplets
Which massivly deflated me and made me realsie I might be more of a Poodle than a Labrador
Mike
First, I should point (pun intended) that Poodles are No 2 in the dog intelligence stakes, whereas Labradors are No 7. So well done on your promotion! (I, being of Welsh extraction, am, of course, a Border Collie, although my wife puts me about twenty places lower than an Afghan Hound. :) )
Second, the term Labrador Puppy is not at all derdogatory! They are enthusiastic, intelligent, full of boundless energy and totally optimistic, just like a Second Lieutenant ... well, apart from the intelligence bit  never give a 2nd Lt a map unless you want to get totally lost.
As to your problem, this is where Labrador Nature comes in handy, as you should view it as a Labrador would view a Brontosaurus(*)  a big collection of bones (unlike my Collie self, which does a quick 180 and applies full military power).
Stuart
(*) Yes, I know it's really an Apatosaurus, but I'm with Gould on this one.
Stuart Bruff wrote:
... First, I should point (pun intended) that Poodles are No 2 in the dog intelligence stakes, whereas Labradors are No 7. So well done on your promotion! (I, being of Welsh extraction, am, of course, a Border Collie, although my wife puts me about twenty places lower than an Afghan Hound. :) )
... As to your problem, this is where Labrador Nature comes in handy, as you should view it as a Labrador would view a Brontosaurus(*)  a big collection of bones (unlike my Collie self, which does a quick 180 and applies full military power).
Actually, thinking about it for a few seconds, I guess this proves my wife's point, as a real Collie would simply give a flock of Brontosauri 'The Eye' and start herding them.
Interesting.
Are you trying to program this case now?
Mike
noting that it doesn't pick up the true prime triplets (2,3,5) & (3,5,7),
You said the only prime triplet was 1,2,3. I took you at your word there, and never even thought about it. It just goes to show that one should always think about what they are reading!
What a wasted opportunity to come up with a smart*** reply
Edit: Oh God! The nannyware kicked in! Perhaps I'm supposed to say smartdonkey reply?
Richard Jackson wrote:
noting that it doesn't pick up the true prime triplets (2,3,5) & (3,5,7),You said the only prime triplet was 1,2,3. I took you at your word there, and never even thought about it. It just goes to show that one should always think about what they are reading!
What a wasted opportunity to come up with a smart*** reply
Edit: Oh God! The nannyware kicked in! Perhaps I'm supposed to say smartdonkey reply?
I did say 'true' triplets, all the rest of them have are separated by more than 2. There are also some variations that I regard as cheating. For example, there are triplets that are consecutive primes but there are also other triplets that match a given pattern, but aren't consecutive (ie, there's one or more other primes in the minimum subsequence containing the triplet.
What a wasted opportunity to come up with a smart*** reply
Edit: Oh God! The nannyware kicked in! Perhaps I'm supposed to say smartdonkey reply?
I'm shocked, Jackson, that you could impugn donkeys in such a way. Is it not enough that we denigrate cats, by attributing feminine malice to them, that we must now resort to defaming equus africanus asinus?
A friend of mine insists on a Right to Reply
I have a related question with the above, and need help.I wish to learn. ( IN .MCD12 ). Assuming that we have a set of Prime Numbers (from 41 to 59). Let's extract Twin Primes and Cousin Primes, and Nonofthose like as the Output below. (or the Output is a similar one).
Thanks in advance.
Loi.
Something like the attached?
Mike
Message was edited by: Mike Armstrong  Worksheet updated due to error
Thank you very much, Mike.
The reason, I need help with this, is I hope to find a way to write a function for Triplet Prime completely. And I have an extension of set of P need help. I hope you understand me. (The attached below).
Regards,
Loi.
I have just noticed an error in my function. 37 shouldn't be getting called up in the 'None of those' categories. I will modify the function to suit.
Do you now want to include Triplet Primes?
I will update my original worksheet to try and keep this thread as clean as possible!!!
Mike
Yes, please. If the output of your function include Triplet Primes, that is good for me, if it does not include Triplet Primes, anyway my question is answered.
Regards,
Loi.
I will have a look tomorrow.
Mike
Have a look at the attached sheet. I think it works.
It doesn't exclude the special case of Triplet primes.
The function is bulky and horrible at the moment and I will have a look at tidying it up.
Cheers
Mike
Mike,
My related question above, and my plan for "Prime Triplet" were answered.(from you, Mike !) (I hope you to understand me. Sometimes I really don't know how to "setup" my question clearly and made you confused many times. Sorry about that.)
Thank you for your time and help.
Regards,
Loi.
Sometimes I really don't know how to "setup" my question clearly and made you confused many times. Sorry about that.)
Don't worry, I confuse myself most of the time.
The function is over the top if you only want Prime Triplets, but if you continue to build the function, eventually it will be able to extract all Prime cases.
Mike
Mike, I have been helped from you with writting a function for Prime Triplets. And now I have a related query with the above, wish learning, and wish be helped with any suggestion. It's about: "Prime Triplets and Extracting Their NonOverlap". Assume having a set of Prime Triplets from 5 to 317.
Thanks in advance.
Regards,
Loi.
Loi,
I will be more than happy to take a look, but I travel to Germany today and will not be able to access the Internet until tomorrow evening.
Mike
Hi,
I have a related question with the above, I am very interested in, wish learning, and need help.
Thank you in advance.
Regards,
Loi.
Mike,
I am not sure how to say it. Probably it is about "Inner match". In other words:
or :
Sorry about my English.
Thanks in advance.
Loi.
Sorry Loi I still don't understand.
t might just be me, but I can't see any logic.
Mike
Am I right in assuming this has nothing to do with Prime numbers?
I will create another thread.
Mike
Have a look at this thread. You query has been answered there.
http://communities.ptc.com/message/156236#156236
Mike
I have a related question with the above, and I am very interested in, wish to learn, and need help. ( IN .MCD12 ). Assuming that we have a set of Prime Numbers (from 17 to 103), extract All of Elements and NONOVERLAP include :Triplet, Twin, Cousin Primes like as the Output below. (or the Output is a similar one).
Thank you in advance.
Regards,
Loi.
Loi,
This thread isn't getting very complicated and even harder to trace.
I will create a new thread with this solution. This will enable collabs to comment and improve the functions posted.
Mike
I know what your after sorry.
I think I can program that. If you don't mind me asking why exactly would you want to exclude overlaps?
Mike
Just for it is less complicated.
Regards,
Loi.
Sorry for taking so long to come back to you, been mad busy.
Your new function request makes no sense. In your image you are requesting No. 41 to be returned in a Triplet prime, but it first appears at the start of vector P and is a Twin Prime with No.43.
What rule are you proposing to dictate that No.41 & 43 don't be returned as Twin Primes?
Mike
I have a related question with the above, I am very interested in, wish learning, and need help. ( IN .MCD11 ). Assuming that having a Nested Array A, Sorting A according to Scalar, like as the Output below. (or the Output is a similar one).
The attached below. (from .mcd12 save as to .mcd11).
Thank you in advance.
Regards,
Loi.
Like the attached?
I have rushed it a little as I'm on my way out  It's Saturday night
Cheers
Mike
I really appreciate your responses, are betimes, Mike.
After being helped from the above, I hope I could write the following function
someday.
Thanks again to all of your time and help.
Regards,
Loi.
I'm sure it can be programmed, but I currently don't have Mathcad.
I will have a look tomorrow.
Mike
Sorry, but that's not correct. Twin primes are pairs of primes that differ by 2, so (23,29) is not a valid pair.
Ooops. Of course not.
Didn't even read the question properly. Just concentrated on nesting every two elements.
Mike
Richard,
Its such a shame that I don't agree with removing posts because this is a valid example of a post needing to be removed.
Mike
Unfortunately, unless they have fixed it so you can delete only your own post and not all the ones subsequent to it, that would delete most of the thread (including Staurt's answer!).
Unfortunately, unless they have fixed it so you can delete only your own post and not all the ones subsequent to it, that would delete most of the thread (including Staurt's answer!).
Think I'll pass on that then.
Mike
Here is a worksheet you might be intrested in. Found in the old collab posted by Jean.
Mike
Like the attached?
Just a word of advice. If somebody posts an answer to the original question don't ask another question and discard the answer. You have asked a question which is a variation to the original thread and created a new Mathcad document without the function supplied by Richard or Stuart.
If you keep all posted functions in the worksheet, all collabs can track the progress of the thread by downloading the latest file.
Mike
Loi Le wrote:
I have still one more extra question and wish to learn.
Thanks in advance.
Loi.
Looks straightforward. Refer to my previous example, add a new variable MTP (merged twin primes), every time you add an item to TP or NTP, add it to MTP. At the end, add MTP to the augment.
Stuart
(I haven't got Mathcad open at the moment (installing something else), so I'm just guessing from what I remember of my function ... sounds OKish, though)
Like the attached?
Mike
Message was edited by: Mike Armstrong  Worksheet saved down. The predefined function used is in the collasped area.
My MC12 cannot open the attached. Please "save as" the attached to .MCD11 or .MCD12.
Thanks again.
Many thanks, Mike.
Loi.
Mike Armstrong wrote:
Like the attached?
Mike
Message was edited by: Mike Armstrong  Worksheet saved down. The predefined function used is in the collasped area.
Mike,
Just a quick note. In my later worksheets, I've dropped the term 'ravel' and replaced it with 'vec'.
'ravel' is a term, that as far as I can determine, was first widely used in the programming language APL and has continued on into APL's 'successor', J, and some other vector languages. However, 'vec' appears to be more widely used in matrix theory and linear algebra. Given that the idea of Mathcad is to be an Engineer's, Scientist's, Mathematician's whiteboard, I thought I'd switch from ravel to vec.
Initially, I used vec as a general purpose function for integer sequences if the input was a scalar. However, as time went on, I thought it was more consistent to get vec to change a scalar into a singleelement array and introduce the function 'seq' to generate sequences. Currently, the only difference between vec and seq is in the handling of scalars, but I might have a think about seq to see if I can make it more useful for sequence generation ... I've already created a few variants that handle different data types and more complex sequences.
Stuart
The attached worksheet has some behavioural differences between versions of Mathcad. M13..M15 will handle an expression of the form v:=vec(rv) where rv is a range variable, M11 won't. M11, M13..M15 will handle v:=vec(rd) where rd is a range definition (ie, expression of form a,b..c).
Mike Armstrong wrote:
Very nice. Particulary like the seq(n) function.
I have been using the following function posted by Richard, but your seq function seems to have the advantage of taking a scalar.
Been having a think and I've got no idea how you could improve the seq function.
Mike
OK. What's one of the annoyances you've got with the limitations of range variables? What data types can't you express as a range?
I'll see if I can dig up the worksheet I was working on a bit ago.
Stuart
OK. What's one of the annoyances you've got with the limitations of range variables? What data types can't you express as a range?
Is that a rhetorical question?
Mike
Mike Armstrong wrote:
OK. What's one of the annoyances you've got with the limitations of range variables? What data types can't you express as a range?
Is that a rhetorical question?
Mike
Do I look like a rhetorical kind of guy? I'm much too simple to indulge in rhetoric.
Think about the kind of sequences that a range variable generates. Are there any sequences you'd like to generate that you can't? Or any that Mathcad should be able to generate but can't? Eg, data types?
Stuart