How to refer to “equivalent” algorithmsHow do I check if an array includes an object in JavaScript?What is the best algorithm for an overridden System.Object.GetHashCode?Easy interview question got harder: given numbers 1..100, find the missing number(s)Ukkonen's suffix tree algorithm in plain EnglishImage Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionHow to find time complexity of an algorithmHow do I determine whether my calculation of pi is accurate?How to pair socks from a pile efficiently?What is the optimal algorithm for the game 2048?Alternate plain English algorithm for Towers of Hanoi
What does the "3am" section means in manpages?
Freedom of speech and where it applies
Are Warlocks Arcane or Divine?
What to do when my ideas aren't chosen, when I strongly disagree with the chosen solution?
Can I rely on these GitHub repository files?
In Star Trek IV, why did the Bounty go back to a time when whales were already rare?
Did US corporations pay demonstrators in the German demonstrations against article 13?
Bob has never been a M before
"lassen" in meaning "sich fassen"
Can a Gentile theist be saved?
Should my PhD thesis be submitted under my legal name?
Do all polymers contain either carbon or silicon?
Resetting two CD4017 counters simultaneously, only one resets
Why does this part of the Space Shuttle launch pad seem to be floating in air?
The One-Electron Universe postulate is true - what simple change can I make to change the whole universe?
How to prevent YouTube from showing already watched videos?
My boss asked me to take a one-day class, then signs it up as a day off
How to color a zone in Tikz
Can the harmonic series explain the origin of the major scale?
Who must act to prevent Brexit on March 29th?
How to deal with or prevent idle in the test team?
Adding empty element to declared container without declaring type of element
How do I repair my stair bannister?
Can somebody explain Brexit in a few child-proof sentences?
How to refer to “equivalent” algorithms
How do I check if an array includes an object in JavaScript?What is the best algorithm for an overridden System.Object.GetHashCode?Easy interview question got harder: given numbers 1..100, find the missing number(s)Ukkonen's suffix tree algorithm in plain EnglishImage Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionHow to find time complexity of an algorithmHow do I determine whether my calculation of pi is accurate?How to pair socks from a pile efficiently?What is the optimal algorithm for the game 2048?Alternate plain English algorithm for Towers of Hanoi
This is a bit of a "soft question", so if this is not the appropriate place to post, please let me know.
Essentially I'm wondering how to talk about algorithms which are "equivalent" in some sense but "different" in others.
Here is a toy example. Suppose we are given a list of numbers list
of length n
. Two simple ways to add up the numbers in the list are given below. Obviously these methods are exactly the same in exact arithmetic, but in floating point arithmetic might give different results.
add_list_1(list,n):
sum = 0
for i=1,2,...,n:
sum += list[i]
return sum
add_list_2(list,n):
sum = 0
for i=n,...,2,1:
sum += list[i]
return sum
This is a very common thing to happen with numerical algorithms, with Gram-Schmidt vs Modified Gram Schmidt being perhaps the most well known example.
The wikipedia page for algorithms mentions "high level description", "implementation description", and "formal description".
Obviously, the implementation and formal descriptions vary, but a high level description such as "add up the list" is the same for both.
Are these different algorithms, different implementations of the same algorithm, or something else entirely? How would you describe algorithms where the high level level description is the same but the implementation is different when talking about them?
algorithm math communication
add a comment |
This is a bit of a "soft question", so if this is not the appropriate place to post, please let me know.
Essentially I'm wondering how to talk about algorithms which are "equivalent" in some sense but "different" in others.
Here is a toy example. Suppose we are given a list of numbers list
of length n
. Two simple ways to add up the numbers in the list are given below. Obviously these methods are exactly the same in exact arithmetic, but in floating point arithmetic might give different results.
add_list_1(list,n):
sum = 0
for i=1,2,...,n:
sum += list[i]
return sum
add_list_2(list,n):
sum = 0
for i=n,...,2,1:
sum += list[i]
return sum
This is a very common thing to happen with numerical algorithms, with Gram-Schmidt vs Modified Gram Schmidt being perhaps the most well known example.
The wikipedia page for algorithms mentions "high level description", "implementation description", and "formal description".
Obviously, the implementation and formal descriptions vary, but a high level description such as "add up the list" is the same for both.
Are these different algorithms, different implementations of the same algorithm, or something else entirely? How would you describe algorithms where the high level level description is the same but the implementation is different when talking about them?
algorithm math communication
1
Imho, the algorithm itself is a high level description, that is not connected to the implementation. So I'd say that your toy example shows 2 different implementations of one algorithm which would have a linefor all items in the list d
.... but very interesting question indeed.
– m.raynal
Mar 21 at 15:05
3
This is not an easy question, mostly because there are many ways in which two "similar" algorithms may differ. In your example, it's a (potentially) different result due to limited precision, but we can also compare algorithms with different efficiencies (e.g. sorting), exact vs approximate solutions that converge on infinity, etc. I think I'd tend to use "conceptually" or "mathematically" equivalent, but in the end it would probably be necessary to specify in each specific case the practical differences between the two, if any, and why you'd choose one over the other.
– jdehesa
Mar 21 at 15:21
3
This might be better asked on Computer Science. An obstruction to having a satisfactory answer is that to answer the question precisely you would need a formal definition of algorithms which will lead to something like Turing machines or some other formal model of computation. But at this level of abstraction, you have subtly changed the topic. On the other hand, if you try to answer the question without a formal definition of what you mean by an algorithm, then it becomes a question of semantics with no definitive answer (in other words -- you are left with a "soft question").
– John Coleman
Mar 21 at 15:51
Are you referring to algorithms that may be more "robust" (numerically stable) than others in performing a task; for example, the Welford algorithm of calculating the mean as opposed to a naive sum-then-divide; or different ways to solve quadratic equations?
– Peter O.
Mar 22 at 3:15
add a comment |
This is a bit of a "soft question", so if this is not the appropriate place to post, please let me know.
Essentially I'm wondering how to talk about algorithms which are "equivalent" in some sense but "different" in others.
Here is a toy example. Suppose we are given a list of numbers list
of length n
. Two simple ways to add up the numbers in the list are given below. Obviously these methods are exactly the same in exact arithmetic, but in floating point arithmetic might give different results.
add_list_1(list,n):
sum = 0
for i=1,2,...,n:
sum += list[i]
return sum
add_list_2(list,n):
sum = 0
for i=n,...,2,1:
sum += list[i]
return sum
This is a very common thing to happen with numerical algorithms, with Gram-Schmidt vs Modified Gram Schmidt being perhaps the most well known example.
The wikipedia page for algorithms mentions "high level description", "implementation description", and "formal description".
Obviously, the implementation and formal descriptions vary, but a high level description such as "add up the list" is the same for both.
Are these different algorithms, different implementations of the same algorithm, or something else entirely? How would you describe algorithms where the high level level description is the same but the implementation is different when talking about them?
algorithm math communication
This is a bit of a "soft question", so if this is not the appropriate place to post, please let me know.
Essentially I'm wondering how to talk about algorithms which are "equivalent" in some sense but "different" in others.
Here is a toy example. Suppose we are given a list of numbers list
of length n
. Two simple ways to add up the numbers in the list are given below. Obviously these methods are exactly the same in exact arithmetic, but in floating point arithmetic might give different results.
add_list_1(list,n):
sum = 0
for i=1,2,...,n:
sum += list[i]
return sum
add_list_2(list,n):
sum = 0
for i=n,...,2,1:
sum += list[i]
return sum
This is a very common thing to happen with numerical algorithms, with Gram-Schmidt vs Modified Gram Schmidt being perhaps the most well known example.
The wikipedia page for algorithms mentions "high level description", "implementation description", and "formal description".
Obviously, the implementation and formal descriptions vary, but a high level description such as "add up the list" is the same for both.
Are these different algorithms, different implementations of the same algorithm, or something else entirely? How would you describe algorithms where the high level level description is the same but the implementation is different when talking about them?
algorithm math communication
algorithm math communication
edited Mar 21 at 15:04
tch
asked Mar 21 at 14:48
tchtch
51526
51526
1
Imho, the algorithm itself is a high level description, that is not connected to the implementation. So I'd say that your toy example shows 2 different implementations of one algorithm which would have a linefor all items in the list d
.... but very interesting question indeed.
– m.raynal
Mar 21 at 15:05
3
This is not an easy question, mostly because there are many ways in which two "similar" algorithms may differ. In your example, it's a (potentially) different result due to limited precision, but we can also compare algorithms with different efficiencies (e.g. sorting), exact vs approximate solutions that converge on infinity, etc. I think I'd tend to use "conceptually" or "mathematically" equivalent, but in the end it would probably be necessary to specify in each specific case the practical differences between the two, if any, and why you'd choose one over the other.
– jdehesa
Mar 21 at 15:21
3
This might be better asked on Computer Science. An obstruction to having a satisfactory answer is that to answer the question precisely you would need a formal definition of algorithms which will lead to something like Turing machines or some other formal model of computation. But at this level of abstraction, you have subtly changed the topic. On the other hand, if you try to answer the question without a formal definition of what you mean by an algorithm, then it becomes a question of semantics with no definitive answer (in other words -- you are left with a "soft question").
– John Coleman
Mar 21 at 15:51
Are you referring to algorithms that may be more "robust" (numerically stable) than others in performing a task; for example, the Welford algorithm of calculating the mean as opposed to a naive sum-then-divide; or different ways to solve quadratic equations?
– Peter O.
Mar 22 at 3:15
add a comment |
1
Imho, the algorithm itself is a high level description, that is not connected to the implementation. So I'd say that your toy example shows 2 different implementations of one algorithm which would have a linefor all items in the list d
.... but very interesting question indeed.
– m.raynal
Mar 21 at 15:05
3
This is not an easy question, mostly because there are many ways in which two "similar" algorithms may differ. In your example, it's a (potentially) different result due to limited precision, but we can also compare algorithms with different efficiencies (e.g. sorting), exact vs approximate solutions that converge on infinity, etc. I think I'd tend to use "conceptually" or "mathematically" equivalent, but in the end it would probably be necessary to specify in each specific case the practical differences between the two, if any, and why you'd choose one over the other.
– jdehesa
Mar 21 at 15:21
3
This might be better asked on Computer Science. An obstruction to having a satisfactory answer is that to answer the question precisely you would need a formal definition of algorithms which will lead to something like Turing machines or some other formal model of computation. But at this level of abstraction, you have subtly changed the topic. On the other hand, if you try to answer the question without a formal definition of what you mean by an algorithm, then it becomes a question of semantics with no definitive answer (in other words -- you are left with a "soft question").
– John Coleman
Mar 21 at 15:51
Are you referring to algorithms that may be more "robust" (numerically stable) than others in performing a task; for example, the Welford algorithm of calculating the mean as opposed to a naive sum-then-divide; or different ways to solve quadratic equations?
– Peter O.
Mar 22 at 3:15
1
1
Imho, the algorithm itself is a high level description, that is not connected to the implementation. So I'd say that your toy example shows 2 different implementations of one algorithm which would have a line
for all items in the list d
.... but very interesting question indeed.– m.raynal
Mar 21 at 15:05
Imho, the algorithm itself is a high level description, that is not connected to the implementation. So I'd say that your toy example shows 2 different implementations of one algorithm which would have a line
for all items in the list d
.... but very interesting question indeed.– m.raynal
Mar 21 at 15:05
3
3
This is not an easy question, mostly because there are many ways in which two "similar" algorithms may differ. In your example, it's a (potentially) different result due to limited precision, but we can also compare algorithms with different efficiencies (e.g. sorting), exact vs approximate solutions that converge on infinity, etc. I think I'd tend to use "conceptually" or "mathematically" equivalent, but in the end it would probably be necessary to specify in each specific case the practical differences between the two, if any, and why you'd choose one over the other.
– jdehesa
Mar 21 at 15:21
This is not an easy question, mostly because there are many ways in which two "similar" algorithms may differ. In your example, it's a (potentially) different result due to limited precision, but we can also compare algorithms with different efficiencies (e.g. sorting), exact vs approximate solutions that converge on infinity, etc. I think I'd tend to use "conceptually" or "mathematically" equivalent, but in the end it would probably be necessary to specify in each specific case the practical differences between the two, if any, and why you'd choose one over the other.
– jdehesa
Mar 21 at 15:21
3
3
This might be better asked on Computer Science. An obstruction to having a satisfactory answer is that to answer the question precisely you would need a formal definition of algorithms which will lead to something like Turing machines or some other formal model of computation. But at this level of abstraction, you have subtly changed the topic. On the other hand, if you try to answer the question without a formal definition of what you mean by an algorithm, then it becomes a question of semantics with no definitive answer (in other words -- you are left with a "soft question").
– John Coleman
Mar 21 at 15:51
This might be better asked on Computer Science. An obstruction to having a satisfactory answer is that to answer the question precisely you would need a formal definition of algorithms which will lead to something like Turing machines or some other formal model of computation. But at this level of abstraction, you have subtly changed the topic. On the other hand, if you try to answer the question without a formal definition of what you mean by an algorithm, then it becomes a question of semantics with no definitive answer (in other words -- you are left with a "soft question").
– John Coleman
Mar 21 at 15:51
Are you referring to algorithms that may be more "robust" (numerically stable) than others in performing a task; for example, the Welford algorithm of calculating the mean as opposed to a naive sum-then-divide; or different ways to solve quadratic equations?
– Peter O.
Mar 22 at 3:15
Are you referring to algorithms that may be more "robust" (numerically stable) than others in performing a task; for example, the Welford algorithm of calculating the mean as opposed to a naive sum-then-divide; or different ways to solve quadratic equations?
– Peter O.
Mar 22 at 3:15
add a comment |
3 Answers
3
active
oldest
votes
The following definition can be found on the Info for the algorithm
tag.
An algorithm is a set of ordered instructions based on a formal language with the following conditions:
Finite. The number of instructions must be finite.
Executable. All instructions must be executable in some language-dependent way, in a finite amount of time.
Considering especially
set of ordered instructions based on a formal language
What this tells us is that the order of the instructions matter. While the outcome of two different algorithms might be the same, it does not imply that the algorithms are the same.
Your example of Gram-Schmidt vs. Modified Gram-Schmidt is an interesting one. Looking at the structure of each algorithm as defined here, these are indeed different algorithms, even on a high level description. The steps are in different orders.
One important distinction you need to make is between a set of instructions and the output set. Here you can find a description of three shortest path algorithms. The set of possible results based on input is the same but they are three very distinct algorithms. And they also have three completely different high level descriptions. To someone who does not care about that though these "do the same" (almost hurts me to write this) and are equivalent.
Another important distinction is the similarity of steps between to algorithms. Let's take your example and write it in a bit more formal notation:
procedure 1 (list, n):
let sum = 0
for i = 1 : n
sum = sum + list[i]
end for
sum //using implicit return
procedure 2 (list, n):
let sum = 0
for i = n : 1
sum = sum + list[i]
end for
sum //using implicit return
These two pieces of code have the same set of results but the instructions seem differently ordered. Still this is not true on a high level. It depends on how you formalise the procedures. Loops are one of those things that if we reduce them to indices they change our procedure. In this particular case though (as already pointed out in the comments), we can essentially substitute the loop for a more formalised for each
loop.
procedure 3 (list):
let sum = 0
for each element in list
sum = sum + element
end for
sum
procedure 3
now does the same things as procedure 1
and procedure 2
, their result is the same but the instructions again seem different. So the procedures are equivalent algorithms but not the same on the implementation level. They are not the same since the order in which the instructions for summing are executed is different for procedure 1
and procedure 2
and completely ignored in procedure 3
(it depends on your implementation of for each
!).
This is where the concepts of a high level description comes in. It is the same for all three algorithms as you already pointed out. The following is from the Wikipedia article you are referring to.
1 High-level description
"...prose to describe an algorithm, ignoring the implementation details. At this level, we do not need to mention how the machine manages its tape or head."
2 Implementation description
"...prose used to define the way the Turing machine uses its head and the way that it stores data on its tape. At this level, we do not give details of states or transition function."
3 Formal description
Most detailed, "lowest level", gives the Turing machine's "state table".
Keeping this in mind your question really depends on the context it is posed in. All three procedures on a high level are the same:
1. Let sum = 0
2. For every element in list add the element to sum
3. Return sum
We do not care how we go through the list or how we sum, just that we do.
On the implementation level we already see a divergence. The procedures move differently over the "tape" but store the information in the same way. While procedure 1
moves "right" on the tape from a starting position, procedure 2
moves "left" on the tape from the "end" (careful with this because there is no such thing in a TM, it has to be defined with a different state, which we do not use in this level).procedure 3
, well it is not defined well enough to make that distinction.
On the low level we need to be very precise. I am not going down to the level of a TM state table thus please accept this rather informal procedure description.
procedure 1
:
1. Move right until you hit an unmarked integer or the "end"
//In an actual TM this would not work, just for simplification I am using ints
1.e. If you hit the end terminate //(i = n)
2. Record value //(sum += list[i]) (of course this is a lot longer in an actual TM)
3. Go back until you find the first marked number
4. Go to 1.
procedure 2
would be the reverse on instructions 1.
and 3.
, thus they are not the same.
But on these different levels are these procedures equivalent? According to Merriam Webster, I'd say they are on all levels. Their "value" or better their "output" is the same for the same input**. The issue with the communication is that these algorithms, like you already stated in your question return the same making them equivalent but not the same.
You referring to **floating point inaccuracy implies implementation level, on which the two algorithms are already different. As a mathematical model we do not have to worry about floating point inaccuracy because there is no such thing in mathematics (mathematicians live in a "perfect" world).
These algorithms are the different implementation level descriptions of the same high level description. Thus, I would refer to different implementations of the same high level algorithm since the idea is the same.
The last important distinction is the further formalisation of an algorithm by assigning it to a set for its complexity (as pointed out perfectly in the comments by @jdehesa). If you just use big omicron, well... your sets are going to be huge and make more algorithms "equivalent". This is because both merge sort and bubble sort are both members of the set O(n^2)
for their time complexity (very unprecise but n^2
is an upper bound for both). Obviously bubble sort is not in O(n*log[2](n))
but this description does not specify that. If we use big theta then bubble and merge sort are not in the same set anymore, context matters. There is more to describing an algorithm than just its steps and that is one more way you can keep in mind to distinguish algorithms.
To sum up: it depends on context, especially who you are talking to. If you are comparing algorithms, make sure that you specify the level you are doing it on. To an amateur saying "add up the list" will be good enough, for your docs use a high level description, when explaining your code explain your implementation of the above high level, and when you really need to formalise your idea before putting it in code use a formal description. Latter will also allow you to prove that your program executes correctly. Of course, nowadays you do not have to write all the states of the underlying TM anymore. When you describe your algorithms, do it in the appropriate form for the setting. And if you have two different implementations of the same high level algorithm just point out the differences on the implementation level (direction of traversal, implementation of summing, format of return values etc.).
add a comment |
I guess, you could call it an ambiguous algorithm. Although this term may not be well defined in literature, consider your example on adding the list of elements.
It could be defined as
1. Initialize sum to zero
2. Add elements in the list to sum one by one.
3. return the sum
The second part is ambiguous, you can add them in any order as its not defined in the algorithm statement and the sum may change in floating point arithematic
One good example I came across: cornell lecture slide. That messy sandwich example is golden.
You could read what the term Ambiguity gererally refers to here wiki, Its applied in various contexts including computer science algorithms.
I love the example from the slides and the word ambiguous algorithm, too. The one thing I am wondering is if their definition of ambiguity is not more related to the outcome? In this particular example your description is perfectly fine on a high level since the order in which you add is not important. When putting a sandwich together the sides the spreads are on is important.
– MrDeal
Mar 21 at 18:36
Both are important and ambiguous when you tell a computer. But when you ask a normal person with some common sense, he will add the list one by one from start and make sandwich with butter and jelly together.
– HariUserX
Mar 21 at 18:42
add a comment |
You may be referring to algorithms that, at least at the surface, perform the same underlying task, but have different levels of numerical stability ("robustness"). Two examples of this may be—
calculating mean and variance (where the so-called "Welford algorithm" is more numerically stable than the naive approach), and
solving a quadratic equation (with many formulas with different "robustness" to choose from).
"Equivalent" algorithms may also include algorithms that are not deterministic, or not consistent between computer systems, or both; for example, due to differences in implementation of floating-point numbers and/or floating-point math, or in the order in which parallel operations finish. This is especially problematic for applications that care about repeatable "random" number generation.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283159%2fhow-to-refer-to-equivalent-algorithms%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following definition can be found on the Info for the algorithm
tag.
An algorithm is a set of ordered instructions based on a formal language with the following conditions:
Finite. The number of instructions must be finite.
Executable. All instructions must be executable in some language-dependent way, in a finite amount of time.
Considering especially
set of ordered instructions based on a formal language
What this tells us is that the order of the instructions matter. While the outcome of two different algorithms might be the same, it does not imply that the algorithms are the same.
Your example of Gram-Schmidt vs. Modified Gram-Schmidt is an interesting one. Looking at the structure of each algorithm as defined here, these are indeed different algorithms, even on a high level description. The steps are in different orders.
One important distinction you need to make is between a set of instructions and the output set. Here you can find a description of three shortest path algorithms. The set of possible results based on input is the same but they are three very distinct algorithms. And they also have three completely different high level descriptions. To someone who does not care about that though these "do the same" (almost hurts me to write this) and are equivalent.
Another important distinction is the similarity of steps between to algorithms. Let's take your example and write it in a bit more formal notation:
procedure 1 (list, n):
let sum = 0
for i = 1 : n
sum = sum + list[i]
end for
sum //using implicit return
procedure 2 (list, n):
let sum = 0
for i = n : 1
sum = sum + list[i]
end for
sum //using implicit return
These two pieces of code have the same set of results but the instructions seem differently ordered. Still this is not true on a high level. It depends on how you formalise the procedures. Loops are one of those things that if we reduce them to indices they change our procedure. In this particular case though (as already pointed out in the comments), we can essentially substitute the loop for a more formalised for each
loop.
procedure 3 (list):
let sum = 0
for each element in list
sum = sum + element
end for
sum
procedure 3
now does the same things as procedure 1
and procedure 2
, their result is the same but the instructions again seem different. So the procedures are equivalent algorithms but not the same on the implementation level. They are not the same since the order in which the instructions for summing are executed is different for procedure 1
and procedure 2
and completely ignored in procedure 3
(it depends on your implementation of for each
!).
This is where the concepts of a high level description comes in. It is the same for all three algorithms as you already pointed out. The following is from the Wikipedia article you are referring to.
1 High-level description
"...prose to describe an algorithm, ignoring the implementation details. At this level, we do not need to mention how the machine manages its tape or head."
2 Implementation description
"...prose used to define the way the Turing machine uses its head and the way that it stores data on its tape. At this level, we do not give details of states or transition function."
3 Formal description
Most detailed, "lowest level", gives the Turing machine's "state table".
Keeping this in mind your question really depends on the context it is posed in. All three procedures on a high level are the same:
1. Let sum = 0
2. For every element in list add the element to sum
3. Return sum
We do not care how we go through the list or how we sum, just that we do.
On the implementation level we already see a divergence. The procedures move differently over the "tape" but store the information in the same way. While procedure 1
moves "right" on the tape from a starting position, procedure 2
moves "left" on the tape from the "end" (careful with this because there is no such thing in a TM, it has to be defined with a different state, which we do not use in this level).procedure 3
, well it is not defined well enough to make that distinction.
On the low level we need to be very precise. I am not going down to the level of a TM state table thus please accept this rather informal procedure description.
procedure 1
:
1. Move right until you hit an unmarked integer or the "end"
//In an actual TM this would not work, just for simplification I am using ints
1.e. If you hit the end terminate //(i = n)
2. Record value //(sum += list[i]) (of course this is a lot longer in an actual TM)
3. Go back until you find the first marked number
4. Go to 1.
procedure 2
would be the reverse on instructions 1.
and 3.
, thus they are not the same.
But on these different levels are these procedures equivalent? According to Merriam Webster, I'd say they are on all levels. Their "value" or better their "output" is the same for the same input**. The issue with the communication is that these algorithms, like you already stated in your question return the same making them equivalent but not the same.
You referring to **floating point inaccuracy implies implementation level, on which the two algorithms are already different. As a mathematical model we do not have to worry about floating point inaccuracy because there is no such thing in mathematics (mathematicians live in a "perfect" world).
These algorithms are the different implementation level descriptions of the same high level description. Thus, I would refer to different implementations of the same high level algorithm since the idea is the same.
The last important distinction is the further formalisation of an algorithm by assigning it to a set for its complexity (as pointed out perfectly in the comments by @jdehesa). If you just use big omicron, well... your sets are going to be huge and make more algorithms "equivalent". This is because both merge sort and bubble sort are both members of the set O(n^2)
for their time complexity (very unprecise but n^2
is an upper bound for both). Obviously bubble sort is not in O(n*log[2](n))
but this description does not specify that. If we use big theta then bubble and merge sort are not in the same set anymore, context matters. There is more to describing an algorithm than just its steps and that is one more way you can keep in mind to distinguish algorithms.
To sum up: it depends on context, especially who you are talking to. If you are comparing algorithms, make sure that you specify the level you are doing it on. To an amateur saying "add up the list" will be good enough, for your docs use a high level description, when explaining your code explain your implementation of the above high level, and when you really need to formalise your idea before putting it in code use a formal description. Latter will also allow you to prove that your program executes correctly. Of course, nowadays you do not have to write all the states of the underlying TM anymore. When you describe your algorithms, do it in the appropriate form for the setting. And if you have two different implementations of the same high level algorithm just point out the differences on the implementation level (direction of traversal, implementation of summing, format of return values etc.).
add a comment |
The following definition can be found on the Info for the algorithm
tag.
An algorithm is a set of ordered instructions based on a formal language with the following conditions:
Finite. The number of instructions must be finite.
Executable. All instructions must be executable in some language-dependent way, in a finite amount of time.
Considering especially
set of ordered instructions based on a formal language
What this tells us is that the order of the instructions matter. While the outcome of two different algorithms might be the same, it does not imply that the algorithms are the same.
Your example of Gram-Schmidt vs. Modified Gram-Schmidt is an interesting one. Looking at the structure of each algorithm as defined here, these are indeed different algorithms, even on a high level description. The steps are in different orders.
One important distinction you need to make is between a set of instructions and the output set. Here you can find a description of three shortest path algorithms. The set of possible results based on input is the same but they are three very distinct algorithms. And they also have three completely different high level descriptions. To someone who does not care about that though these "do the same" (almost hurts me to write this) and are equivalent.
Another important distinction is the similarity of steps between to algorithms. Let's take your example and write it in a bit more formal notation:
procedure 1 (list, n):
let sum = 0
for i = 1 : n
sum = sum + list[i]
end for
sum //using implicit return
procedure 2 (list, n):
let sum = 0
for i = n : 1
sum = sum + list[i]
end for
sum //using implicit return
These two pieces of code have the same set of results but the instructions seem differently ordered. Still this is not true on a high level. It depends on how you formalise the procedures. Loops are one of those things that if we reduce them to indices they change our procedure. In this particular case though (as already pointed out in the comments), we can essentially substitute the loop for a more formalised for each
loop.
procedure 3 (list):
let sum = 0
for each element in list
sum = sum + element
end for
sum
procedure 3
now does the same things as procedure 1
and procedure 2
, their result is the same but the instructions again seem different. So the procedures are equivalent algorithms but not the same on the implementation level. They are not the same since the order in which the instructions for summing are executed is different for procedure 1
and procedure 2
and completely ignored in procedure 3
(it depends on your implementation of for each
!).
This is where the concepts of a high level description comes in. It is the same for all three algorithms as you already pointed out. The following is from the Wikipedia article you are referring to.
1 High-level description
"...prose to describe an algorithm, ignoring the implementation details. At this level, we do not need to mention how the machine manages its tape or head."
2 Implementation description
"...prose used to define the way the Turing machine uses its head and the way that it stores data on its tape. At this level, we do not give details of states or transition function."
3 Formal description
Most detailed, "lowest level", gives the Turing machine's "state table".
Keeping this in mind your question really depends on the context it is posed in. All three procedures on a high level are the same:
1. Let sum = 0
2. For every element in list add the element to sum
3. Return sum
We do not care how we go through the list or how we sum, just that we do.
On the implementation level we already see a divergence. The procedures move differently over the "tape" but store the information in the same way. While procedure 1
moves "right" on the tape from a starting position, procedure 2
moves "left" on the tape from the "end" (careful with this because there is no such thing in a TM, it has to be defined with a different state, which we do not use in this level).procedure 3
, well it is not defined well enough to make that distinction.
On the low level we need to be very precise. I am not going down to the level of a TM state table thus please accept this rather informal procedure description.
procedure 1
:
1. Move right until you hit an unmarked integer or the "end"
//In an actual TM this would not work, just for simplification I am using ints
1.e. If you hit the end terminate //(i = n)
2. Record value //(sum += list[i]) (of course this is a lot longer in an actual TM)
3. Go back until you find the first marked number
4. Go to 1.
procedure 2
would be the reverse on instructions 1.
and 3.
, thus they are not the same.
But on these different levels are these procedures equivalent? According to Merriam Webster, I'd say they are on all levels. Their "value" or better their "output" is the same for the same input**. The issue with the communication is that these algorithms, like you already stated in your question return the same making them equivalent but not the same.
You referring to **floating point inaccuracy implies implementation level, on which the two algorithms are already different. As a mathematical model we do not have to worry about floating point inaccuracy because there is no such thing in mathematics (mathematicians live in a "perfect" world).
These algorithms are the different implementation level descriptions of the same high level description. Thus, I would refer to different implementations of the same high level algorithm since the idea is the same.
The last important distinction is the further formalisation of an algorithm by assigning it to a set for its complexity (as pointed out perfectly in the comments by @jdehesa). If you just use big omicron, well... your sets are going to be huge and make more algorithms "equivalent". This is because both merge sort and bubble sort are both members of the set O(n^2)
for their time complexity (very unprecise but n^2
is an upper bound for both). Obviously bubble sort is not in O(n*log[2](n))
but this description does not specify that. If we use big theta then bubble and merge sort are not in the same set anymore, context matters. There is more to describing an algorithm than just its steps and that is one more way you can keep in mind to distinguish algorithms.
To sum up: it depends on context, especially who you are talking to. If you are comparing algorithms, make sure that you specify the level you are doing it on. To an amateur saying "add up the list" will be good enough, for your docs use a high level description, when explaining your code explain your implementation of the above high level, and when you really need to formalise your idea before putting it in code use a formal description. Latter will also allow you to prove that your program executes correctly. Of course, nowadays you do not have to write all the states of the underlying TM anymore. When you describe your algorithms, do it in the appropriate form for the setting. And if you have two different implementations of the same high level algorithm just point out the differences on the implementation level (direction of traversal, implementation of summing, format of return values etc.).
add a comment |
The following definition can be found on the Info for the algorithm
tag.
An algorithm is a set of ordered instructions based on a formal language with the following conditions:
Finite. The number of instructions must be finite.
Executable. All instructions must be executable in some language-dependent way, in a finite amount of time.
Considering especially
set of ordered instructions based on a formal language
What this tells us is that the order of the instructions matter. While the outcome of two different algorithms might be the same, it does not imply that the algorithms are the same.
Your example of Gram-Schmidt vs. Modified Gram-Schmidt is an interesting one. Looking at the structure of each algorithm as defined here, these are indeed different algorithms, even on a high level description. The steps are in different orders.
One important distinction you need to make is between a set of instructions and the output set. Here you can find a description of three shortest path algorithms. The set of possible results based on input is the same but they are three very distinct algorithms. And they also have three completely different high level descriptions. To someone who does not care about that though these "do the same" (almost hurts me to write this) and are equivalent.
Another important distinction is the similarity of steps between to algorithms. Let's take your example and write it in a bit more formal notation:
procedure 1 (list, n):
let sum = 0
for i = 1 : n
sum = sum + list[i]
end for
sum //using implicit return
procedure 2 (list, n):
let sum = 0
for i = n : 1
sum = sum + list[i]
end for
sum //using implicit return
These two pieces of code have the same set of results but the instructions seem differently ordered. Still this is not true on a high level. It depends on how you formalise the procedures. Loops are one of those things that if we reduce them to indices they change our procedure. In this particular case though (as already pointed out in the comments), we can essentially substitute the loop for a more formalised for each
loop.
procedure 3 (list):
let sum = 0
for each element in list
sum = sum + element
end for
sum
procedure 3
now does the same things as procedure 1
and procedure 2
, their result is the same but the instructions again seem different. So the procedures are equivalent algorithms but not the same on the implementation level. They are not the same since the order in which the instructions for summing are executed is different for procedure 1
and procedure 2
and completely ignored in procedure 3
(it depends on your implementation of for each
!).
This is where the concepts of a high level description comes in. It is the same for all three algorithms as you already pointed out. The following is from the Wikipedia article you are referring to.
1 High-level description
"...prose to describe an algorithm, ignoring the implementation details. At this level, we do not need to mention how the machine manages its tape or head."
2 Implementation description
"...prose used to define the way the Turing machine uses its head and the way that it stores data on its tape. At this level, we do not give details of states or transition function."
3 Formal description
Most detailed, "lowest level", gives the Turing machine's "state table".
Keeping this in mind your question really depends on the context it is posed in. All three procedures on a high level are the same:
1. Let sum = 0
2. For every element in list add the element to sum
3. Return sum
We do not care how we go through the list or how we sum, just that we do.
On the implementation level we already see a divergence. The procedures move differently over the "tape" but store the information in the same way. While procedure 1
moves "right" on the tape from a starting position, procedure 2
moves "left" on the tape from the "end" (careful with this because there is no such thing in a TM, it has to be defined with a different state, which we do not use in this level).procedure 3
, well it is not defined well enough to make that distinction.
On the low level we need to be very precise. I am not going down to the level of a TM state table thus please accept this rather informal procedure description.
procedure 1
:
1. Move right until you hit an unmarked integer or the "end"
//In an actual TM this would not work, just for simplification I am using ints
1.e. If you hit the end terminate //(i = n)
2. Record value //(sum += list[i]) (of course this is a lot longer in an actual TM)
3. Go back until you find the first marked number
4. Go to 1.
procedure 2
would be the reverse on instructions 1.
and 3.
, thus they are not the same.
But on these different levels are these procedures equivalent? According to Merriam Webster, I'd say they are on all levels. Their "value" or better their "output" is the same for the same input**. The issue with the communication is that these algorithms, like you already stated in your question return the same making them equivalent but not the same.
You referring to **floating point inaccuracy implies implementation level, on which the two algorithms are already different. As a mathematical model we do not have to worry about floating point inaccuracy because there is no such thing in mathematics (mathematicians live in a "perfect" world).
These algorithms are the different implementation level descriptions of the same high level description. Thus, I would refer to different implementations of the same high level algorithm since the idea is the same.
The last important distinction is the further formalisation of an algorithm by assigning it to a set for its complexity (as pointed out perfectly in the comments by @jdehesa). If you just use big omicron, well... your sets are going to be huge and make more algorithms "equivalent". This is because both merge sort and bubble sort are both members of the set O(n^2)
for their time complexity (very unprecise but n^2
is an upper bound for both). Obviously bubble sort is not in O(n*log[2](n))
but this description does not specify that. If we use big theta then bubble and merge sort are not in the same set anymore, context matters. There is more to describing an algorithm than just its steps and that is one more way you can keep in mind to distinguish algorithms.
To sum up: it depends on context, especially who you are talking to. If you are comparing algorithms, make sure that you specify the level you are doing it on. To an amateur saying "add up the list" will be good enough, for your docs use a high level description, when explaining your code explain your implementation of the above high level, and when you really need to formalise your idea before putting it in code use a formal description. Latter will also allow you to prove that your program executes correctly. Of course, nowadays you do not have to write all the states of the underlying TM anymore. When you describe your algorithms, do it in the appropriate form for the setting. And if you have two different implementations of the same high level algorithm just point out the differences on the implementation level (direction of traversal, implementation of summing, format of return values etc.).
The following definition can be found on the Info for the algorithm
tag.
An algorithm is a set of ordered instructions based on a formal language with the following conditions:
Finite. The number of instructions must be finite.
Executable. All instructions must be executable in some language-dependent way, in a finite amount of time.
Considering especially
set of ordered instructions based on a formal language
What this tells us is that the order of the instructions matter. While the outcome of two different algorithms might be the same, it does not imply that the algorithms are the same.
Your example of Gram-Schmidt vs. Modified Gram-Schmidt is an interesting one. Looking at the structure of each algorithm as defined here, these are indeed different algorithms, even on a high level description. The steps are in different orders.
One important distinction you need to make is between a set of instructions and the output set. Here you can find a description of three shortest path algorithms. The set of possible results based on input is the same but they are three very distinct algorithms. And they also have three completely different high level descriptions. To someone who does not care about that though these "do the same" (almost hurts me to write this) and are equivalent.
Another important distinction is the similarity of steps between to algorithms. Let's take your example and write it in a bit more formal notation:
procedure 1 (list, n):
let sum = 0
for i = 1 : n
sum = sum + list[i]
end for
sum //using implicit return
procedure 2 (list, n):
let sum = 0
for i = n : 1
sum = sum + list[i]
end for
sum //using implicit return
These two pieces of code have the same set of results but the instructions seem differently ordered. Still this is not true on a high level. It depends on how you formalise the procedures. Loops are one of those things that if we reduce them to indices they change our procedure. In this particular case though (as already pointed out in the comments), we can essentially substitute the loop for a more formalised for each
loop.
procedure 3 (list):
let sum = 0
for each element in list
sum = sum + element
end for
sum
procedure 3
now does the same things as procedure 1
and procedure 2
, their result is the same but the instructions again seem different. So the procedures are equivalent algorithms but not the same on the implementation level. They are not the same since the order in which the instructions for summing are executed is different for procedure 1
and procedure 2
and completely ignored in procedure 3
(it depends on your implementation of for each
!).
This is where the concepts of a high level description comes in. It is the same for all three algorithms as you already pointed out. The following is from the Wikipedia article you are referring to.
1 High-level description
"...prose to describe an algorithm, ignoring the implementation details. At this level, we do not need to mention how the machine manages its tape or head."
2 Implementation description
"...prose used to define the way the Turing machine uses its head and the way that it stores data on its tape. At this level, we do not give details of states or transition function."
3 Formal description
Most detailed, "lowest level", gives the Turing machine's "state table".
Keeping this in mind your question really depends on the context it is posed in. All three procedures on a high level are the same:
1. Let sum = 0
2. For every element in list add the element to sum
3. Return sum
We do not care how we go through the list or how we sum, just that we do.
On the implementation level we already see a divergence. The procedures move differently over the "tape" but store the information in the same way. While procedure 1
moves "right" on the tape from a starting position, procedure 2
moves "left" on the tape from the "end" (careful with this because there is no such thing in a TM, it has to be defined with a different state, which we do not use in this level).procedure 3
, well it is not defined well enough to make that distinction.
On the low level we need to be very precise. I am not going down to the level of a TM state table thus please accept this rather informal procedure description.
procedure 1
:
1. Move right until you hit an unmarked integer or the "end"
//In an actual TM this would not work, just for simplification I am using ints
1.e. If you hit the end terminate //(i = n)
2. Record value //(sum += list[i]) (of course this is a lot longer in an actual TM)
3. Go back until you find the first marked number
4. Go to 1.
procedure 2
would be the reverse on instructions 1.
and 3.
, thus they are not the same.
But on these different levels are these procedures equivalent? According to Merriam Webster, I'd say they are on all levels. Their "value" or better their "output" is the same for the same input**. The issue with the communication is that these algorithms, like you already stated in your question return the same making them equivalent but not the same.
You referring to **floating point inaccuracy implies implementation level, on which the two algorithms are already different. As a mathematical model we do not have to worry about floating point inaccuracy because there is no such thing in mathematics (mathematicians live in a "perfect" world).
These algorithms are the different implementation level descriptions of the same high level description. Thus, I would refer to different implementations of the same high level algorithm since the idea is the same.
The last important distinction is the further formalisation of an algorithm by assigning it to a set for its complexity (as pointed out perfectly in the comments by @jdehesa). If you just use big omicron, well... your sets are going to be huge and make more algorithms "equivalent". This is because both merge sort and bubble sort are both members of the set O(n^2)
for their time complexity (very unprecise but n^2
is an upper bound for both). Obviously bubble sort is not in O(n*log[2](n))
but this description does not specify that. If we use big theta then bubble and merge sort are not in the same set anymore, context matters. There is more to describing an algorithm than just its steps and that is one more way you can keep in mind to distinguish algorithms.
To sum up: it depends on context, especially who you are talking to. If you are comparing algorithms, make sure that you specify the level you are doing it on. To an amateur saying "add up the list" will be good enough, for your docs use a high level description, when explaining your code explain your implementation of the above high level, and when you really need to formalise your idea before putting it in code use a formal description. Latter will also allow you to prove that your program executes correctly. Of course, nowadays you do not have to write all the states of the underlying TM anymore. When you describe your algorithms, do it in the appropriate form for the setting. And if you have two different implementations of the same high level algorithm just point out the differences on the implementation level (direction of traversal, implementation of summing, format of return values etc.).
answered Mar 21 at 18:12
MrDealMrDeal
19610
19610
add a comment |
add a comment |
I guess, you could call it an ambiguous algorithm. Although this term may not be well defined in literature, consider your example on adding the list of elements.
It could be defined as
1. Initialize sum to zero
2. Add elements in the list to sum one by one.
3. return the sum
The second part is ambiguous, you can add them in any order as its not defined in the algorithm statement and the sum may change in floating point arithematic
One good example I came across: cornell lecture slide. That messy sandwich example is golden.
You could read what the term Ambiguity gererally refers to here wiki, Its applied in various contexts including computer science algorithms.
I love the example from the slides and the word ambiguous algorithm, too. The one thing I am wondering is if their definition of ambiguity is not more related to the outcome? In this particular example your description is perfectly fine on a high level since the order in which you add is not important. When putting a sandwich together the sides the spreads are on is important.
– MrDeal
Mar 21 at 18:36
Both are important and ambiguous when you tell a computer. But when you ask a normal person with some common sense, he will add the list one by one from start and make sandwich with butter and jelly together.
– HariUserX
Mar 21 at 18:42
add a comment |
I guess, you could call it an ambiguous algorithm. Although this term may not be well defined in literature, consider your example on adding the list of elements.
It could be defined as
1. Initialize sum to zero
2. Add elements in the list to sum one by one.
3. return the sum
The second part is ambiguous, you can add them in any order as its not defined in the algorithm statement and the sum may change in floating point arithematic
One good example I came across: cornell lecture slide. That messy sandwich example is golden.
You could read what the term Ambiguity gererally refers to here wiki, Its applied in various contexts including computer science algorithms.
I love the example from the slides and the word ambiguous algorithm, too. The one thing I am wondering is if their definition of ambiguity is not more related to the outcome? In this particular example your description is perfectly fine on a high level since the order in which you add is not important. When putting a sandwich together the sides the spreads are on is important.
– MrDeal
Mar 21 at 18:36
Both are important and ambiguous when you tell a computer. But when you ask a normal person with some common sense, he will add the list one by one from start and make sandwich with butter and jelly together.
– HariUserX
Mar 21 at 18:42
add a comment |
I guess, you could call it an ambiguous algorithm. Although this term may not be well defined in literature, consider your example on adding the list of elements.
It could be defined as
1. Initialize sum to zero
2. Add elements in the list to sum one by one.
3. return the sum
The second part is ambiguous, you can add them in any order as its not defined in the algorithm statement and the sum may change in floating point arithematic
One good example I came across: cornell lecture slide. That messy sandwich example is golden.
You could read what the term Ambiguity gererally refers to here wiki, Its applied in various contexts including computer science algorithms.
I guess, you could call it an ambiguous algorithm. Although this term may not be well defined in literature, consider your example on adding the list of elements.
It could be defined as
1. Initialize sum to zero
2. Add elements in the list to sum one by one.
3. return the sum
The second part is ambiguous, you can add them in any order as its not defined in the algorithm statement and the sum may change in floating point arithematic
One good example I came across: cornell lecture slide. That messy sandwich example is golden.
You could read what the term Ambiguity gererally refers to here wiki, Its applied in various contexts including computer science algorithms.
answered Mar 21 at 18:13
HariUserXHariUserX
1,058415
1,058415
I love the example from the slides and the word ambiguous algorithm, too. The one thing I am wondering is if their definition of ambiguity is not more related to the outcome? In this particular example your description is perfectly fine on a high level since the order in which you add is not important. When putting a sandwich together the sides the spreads are on is important.
– MrDeal
Mar 21 at 18:36
Both are important and ambiguous when you tell a computer. But when you ask a normal person with some common sense, he will add the list one by one from start and make sandwich with butter and jelly together.
– HariUserX
Mar 21 at 18:42
add a comment |
I love the example from the slides and the word ambiguous algorithm, too. The one thing I am wondering is if their definition of ambiguity is not more related to the outcome? In this particular example your description is perfectly fine on a high level since the order in which you add is not important. When putting a sandwich together the sides the spreads are on is important.
– MrDeal
Mar 21 at 18:36
Both are important and ambiguous when you tell a computer. But when you ask a normal person with some common sense, he will add the list one by one from start and make sandwich with butter and jelly together.
– HariUserX
Mar 21 at 18:42
I love the example from the slides and the word ambiguous algorithm, too. The one thing I am wondering is if their definition of ambiguity is not more related to the outcome? In this particular example your description is perfectly fine on a high level since the order in which you add is not important. When putting a sandwich together the sides the spreads are on is important.
– MrDeal
Mar 21 at 18:36
I love the example from the slides and the word ambiguous algorithm, too. The one thing I am wondering is if their definition of ambiguity is not more related to the outcome? In this particular example your description is perfectly fine on a high level since the order in which you add is not important. When putting a sandwich together the sides the spreads are on is important.
– MrDeal
Mar 21 at 18:36
Both are important and ambiguous when you tell a computer. But when you ask a normal person with some common sense, he will add the list one by one from start and make sandwich with butter and jelly together.
– HariUserX
Mar 21 at 18:42
Both are important and ambiguous when you tell a computer. But when you ask a normal person with some common sense, he will add the list one by one from start and make sandwich with butter and jelly together.
– HariUserX
Mar 21 at 18:42
add a comment |
You may be referring to algorithms that, at least at the surface, perform the same underlying task, but have different levels of numerical stability ("robustness"). Two examples of this may be—
calculating mean and variance (where the so-called "Welford algorithm" is more numerically stable than the naive approach), and
solving a quadratic equation (with many formulas with different "robustness" to choose from).
"Equivalent" algorithms may also include algorithms that are not deterministic, or not consistent between computer systems, or both; for example, due to differences in implementation of floating-point numbers and/or floating-point math, or in the order in which parallel operations finish. This is especially problematic for applications that care about repeatable "random" number generation.
add a comment |
You may be referring to algorithms that, at least at the surface, perform the same underlying task, but have different levels of numerical stability ("robustness"). Two examples of this may be—
calculating mean and variance (where the so-called "Welford algorithm" is more numerically stable than the naive approach), and
solving a quadratic equation (with many formulas with different "robustness" to choose from).
"Equivalent" algorithms may also include algorithms that are not deterministic, or not consistent between computer systems, or both; for example, due to differences in implementation of floating-point numbers and/or floating-point math, or in the order in which parallel operations finish. This is especially problematic for applications that care about repeatable "random" number generation.
add a comment |
You may be referring to algorithms that, at least at the surface, perform the same underlying task, but have different levels of numerical stability ("robustness"). Two examples of this may be—
calculating mean and variance (where the so-called "Welford algorithm" is more numerically stable than the naive approach), and
solving a quadratic equation (with many formulas with different "robustness" to choose from).
"Equivalent" algorithms may also include algorithms that are not deterministic, or not consistent between computer systems, or both; for example, due to differences in implementation of floating-point numbers and/or floating-point math, or in the order in which parallel operations finish. This is especially problematic for applications that care about repeatable "random" number generation.
You may be referring to algorithms that, at least at the surface, perform the same underlying task, but have different levels of numerical stability ("robustness"). Two examples of this may be—
calculating mean and variance (where the so-called "Welford algorithm" is more numerically stable than the naive approach), and
solving a quadratic equation (with many formulas with different "robustness" to choose from).
"Equivalent" algorithms may also include algorithms that are not deterministic, or not consistent between computer systems, or both; for example, due to differences in implementation of floating-point numbers and/or floating-point math, or in the order in which parallel operations finish. This is especially problematic for applications that care about repeatable "random" number generation.
answered Mar 22 at 3:24
Peter O.Peter O.
21k95969
21k95969
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283159%2fhow-to-refer-to-equivalent-algorithms%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Imho, the algorithm itself is a high level description, that is not connected to the implementation. So I'd say that your toy example shows 2 different implementations of one algorithm which would have a line
for all items in the list d
.... but very interesting question indeed.– m.raynal
Mar 21 at 15:05
3
This is not an easy question, mostly because there are many ways in which two "similar" algorithms may differ. In your example, it's a (potentially) different result due to limited precision, but we can also compare algorithms with different efficiencies (e.g. sorting), exact vs approximate solutions that converge on infinity, etc. I think I'd tend to use "conceptually" or "mathematically" equivalent, but in the end it would probably be necessary to specify in each specific case the practical differences between the two, if any, and why you'd choose one over the other.
– jdehesa
Mar 21 at 15:21
3
This might be better asked on Computer Science. An obstruction to having a satisfactory answer is that to answer the question precisely you would need a formal definition of algorithms which will lead to something like Turing machines or some other formal model of computation. But at this level of abstraction, you have subtly changed the topic. On the other hand, if you try to answer the question without a formal definition of what you mean by an algorithm, then it becomes a question of semantics with no definitive answer (in other words -- you are left with a "soft question").
– John Coleman
Mar 21 at 15:51
Are you referring to algorithms that may be more "robust" (numerically stable) than others in performing a task; for example, the Welford algorithm of calculating the mean as opposed to a naive sum-then-divide; or different ways to solve quadratic equations?
– Peter O.
Mar 22 at 3:15