Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#26 2009-08-13 22:59:01

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,877

Re: Sum of fractions which equals 1

bobbym wrote:

Its ctrl + pause/break : this key is above the arrow keys (at the top).

Ah - found it! I'd never used that key before and must have skimmed over it when looking for it. sad

It stops program execution, as you said.

Thanks!


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#27 2009-08-14 13:29:46

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Sum of fractions which equals 1

Hi phrontister;

I tried that, but I got the same incorrect responses as before. Maybe I didn't code it correctly. I'll try again...

for n=10 to 0 step -1/5
   print n
next  n

Notice how instead of getting 0 he gets 0.20539126e-14, but at least the for next loop terminates.

Last edited by bobbym (2009-08-14 13:30:06)


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#28 2009-08-14 13:37:00

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,877

Re: Sum of fractions which equals 1

Hi Bobby,

bobbym wrote:

Notice how instead of getting 0 he gets 0.20539126e-14, but at least the for next loop terminates.

Yes - I'll have to remember that for situations where that is important (or maybe I should make it a habit anyway).

Some day this quirk won't exist and we won't have to dream up workarounds...and we'll laugh at the clunky ways of the old days.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#29 2009-08-14 13:49:16

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Sum of fractions which equals 1

Hi phrontister;

This problem will always exist with floating point arithmetic, you can delay it with more digits of precision, but when used incorrectly it will bite you.

Exact integer and rational arithmetic do not have this problem but it is not always possible to use them.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#30 2015-03-18 20:15:56

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,996
Website

Re: Sum of fractions which equals 1

Why not try contraint programming here?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#31 2015-03-19 06:33:53

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Sum of fractions which equals 1

Can you set it up?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#32 2015-03-19 12:38:13

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,996
Website

Re: Sum of fractions which equals 1

But not in M


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#33 2015-03-19 13:03:28

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Sum of fractions which equals 1

What then?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#34 2015-03-19 18:45:00

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,996
Website

Re: Sum of fractions which equals 1

Minizinc?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#35 2015-03-19 18:46:37

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Sum of fractions which equals 1

What exactly do you mean by constraint programming?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#36 2015-03-20 01:31:25

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,996
Website

Re: Sum of fractions which equals 1

It is a paradigm where programming is donw by mentioning properties of the soltuion rather than explaining how to compute the solution.


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
I'm not crazy, my mother had me tested.

Offline

#37 2015-03-20 02:06:45

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: Sum of fractions which equals 1

It's something like logic programming except more specialized. And it seems it's often mixed with another paradigm (functional, imperative,...). The two languages mentioned on W are Oz, which is functional, and Kaleidoscope, which is imperative.

Oz seems really interresting.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

Board footer

Powered by FluxBB