Problem 094

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
blegat
Posts: 1
Joined: Wed Feb 22, 2012 2:36 pm

Re: Problem 094

Post by blegat »

Can somebody explain me why 311709883 is not a possible side ?
We have 311709883^2 + (311709884/2)^2 = 269948677^2...
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 094

Post by jaap »

blegat wrote:Can somebody explain me why 311709883 is not a possible side ?
We have 311709883^2 + (311709884/2)^2 = 269948677^2...
311709884/2 is not an integer:
Problem 94 wrote:Find the sum of the perimeters of all almost equilateral triangles with integral side lengths and area
Edit: Ignore that - I didn't see what you meant.
If it were the case that
311709883^2 - (311709884/2)^2 = 269948677^2
(note the minus sign that Francky pointed out)
then it would give rise to one of the requested triangles. It is not correct however.
311709883^2 - (311709884/2)^2 = (269948676,9999999925911...)^2
It is close to an integer. However the last digit of left hand side is 3^2-2^2=5, so the right hand side should also end in a 5 if it were an integer.
In fact:
311709883^2 - (311709884/2)^2 = 72872288214050325
269948677^2 = 72872288214050329
Last edited by jaap on Wed Feb 22, 2012 6:13 pm, edited 4 times in total.
User avatar
Francky
Posts: 90
Joined: Sat May 07, 2011 3:49 pm
Location: South of France

Re: Problem 094

Post by Francky »

blegat wrote:Can somebody explain me why 311709883 is not a possible side ?
We have 311709883^2 + (311709884/2)^2 = 269948677^2...
It would have been better if
311709883^2 - (311709884/2)^2 = anInt^2
ImageEntia non sunt multiplicanda praeter necessitatem
KhaledSharif
Posts: 1
Joined: Thu Aug 30, 2012 7:58 pm

Re: Problem 094

Post by KhaledSharif »

Can someone tell me why the formula for producing isosceles Heronian triangles found here does not produce all the triangles I require?

http://en.wikipedia.org/wiki/Integer_tr ... _triangles
ffff0
Posts: 50
Joined: Sun Aug 21, 2011 6:26 am
Location: Moscow, Russian Federation

Re: Problem 094

Post by ffff0 »

From http://en.wikipedia.org/wiki/Heronian_t ... _triangles:
"For example, taking m = 36, n = 4 and k = 3 produces a triangle with a = 5220, b = 900 and c = 5400, which is similar to the 5, 29, 30 Heronian triangle."

So, you can obtain all triangles with this method, but you'll need a really big upper limit for perimeter.
Image
MukiJames
Posts: 2
Joined: Fri Apr 12, 2013 8:10 am
Location: Allschwil, Schweiz

Re: Problem 094

Post by MukiJames »

Hi,

I tried to apply the already mentioned formula from Wikipedia: http://en.wikipedia.org/wiki/Heronian_t ... _triangles. The Wiki page says: "All Heronian triangles can be generated as multiples of", but as far as I see it is not really true, or I misunderstood the meaning of "multiplies". There are triangles which are not generated by this formula but their multiplications. For example the formula doesn't generate 5-5-6, but 10-10-12 (m=n=2, k=1). This means that I cannot really use this formula because there is no upper limit for perimeter.

Could you give me a hint, what is wrong with my thinking, please?

Thanks in advance.


[Edit]: typo
Last edited by MukiJames on Fri Apr 12, 2013 9:39 am, edited 1 time in total.
Image
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 094

Post by TripleM »

The two posts above yours ask and answer that exact same question :) Nothing is wrong with your thinking; the multiples can indeed be fractional, so using that formula for values underneath a given limit is probably not going to help you (unless you can find another way of bounding them).
MukiJames
Posts: 2
Joined: Fri Apr 12, 2013 8:10 am
Location: Allschwil, Schweiz

Re: Problem 094

Post by MukiJames »

Thanks for the answer. Currently I cannot find out any better solution to find the upper limit for the formula. I think I will look into the next problem now, maybe after a few days I will have a new idea and I will return to this one :)
Image
satyres
Posts: 31
Joined: Thu Feb 20, 2014 2:48 pm

Re: Problem 094

Post by satyres »

I have made an algorithm that show the correct answer but the sum of all permiter is incorrect ! ?
The number is really big and i'm using (unsigned long long) in C++ but it's wrong !
Those numbers are correct ?
12=5 5 6
120=17 17 16
1848=65 65 66
25080=241 241 240
351780=901 901 902
Thanks for the help!
User avatar
dawghaus4
Posts: 56
Joined: Fri Nov 29, 2013 2:22 am

Re: Problem 094

Post by dawghaus4 »

satyres wrote:I have made an algorithm that show the correct answer but the sum of all permiter is incorrect ! ?
The number is really big and i'm using (unsigned long long) in C++ but it's wrong !
Those numbers are correct ?
12=5 5 6
120=17 17 16
1848=65 65 66
25080=241 241 240
351780=901 901 902
Thanks for the help!
The left side of your equals are the correct areas for triangles having sides you have listed on the right side.

If you are using Heron's formula (some refer to it as Hero's formula) to calculate the areas, you will need to use a "big integer" package of some sort. Although the areas will all fit comfortably in 64-bit integers, the squares (before you extract the square roots) will exceed the 64-bit range of values.

You might consider a different approach. (I don't know how much I should say about a different approach.)

Tangentially, how did Heron's name come to be Hero? It is the same way that Platon's name came to be Plato.
satyres
Posts: 31
Joined: Thu Feb 20, 2014 2:48 pm

Re: Problem 094

Post by satyres »

dawghaus4 wrote: The left side of your equals are the correct areas for triangles having sides you have listed on the right side.

If you are using Heron's formula (some refer to it as Hero's formula) to calculate the areas, you will need to use a "big integer" package of some sort. Although the areas will all fit comfortably in 64-bit integers, the squares (before you extract the square roots) will exceed the 64-bit range of values.

You might consider a different approach. (I don't know how much I should say about a different approach.)

Tangentially, how did Heron's name come to be Hero? It is the same way that Platon's name came to be Plato.
Hi , and thanks for the reply !
i did not use any formula ! but i still don't know why my result is wrong !?
User avatar
dawghaus4
Posts: 56
Joined: Fri Nov 29, 2013 2:22 am

Re: Problem 094

Post by dawghaus4 »

It's not possible for us to say what is wrong with your program. In your original post, you hinted that you were concerned about overflow. Certainly, that will cause you to miss. As I stated earlier, Heron's formula will overflow. So will the Pythagorean theorem.

But you said you are not using a formula, so we don't know how you are computing the areas. Regardless, have you verified that overflow is not an issue?

[on edit] The biggest number my program dealt with contained 16 digits.
satyres
Posts: 31
Joined: Thu Feb 20, 2014 2:48 pm

Re: Problem 094

Post by satyres »

dawghaus4 wrote:It's not possible for us to say what is wrong with your program. In your original post, you hinted that you were concerned about overflow. Certainly, that will cause you to miss. As I stated earlier, Heron's formula will overflow. So will the Pythagorean theorem.

But you said you are not using a formula, so we don't know how you are computing the areas. Regardless, have you verified that overflow is not an issue?

[on edit] The biggest number my program dealt with contained 16 digits.
Thanks for the reply !
i have found this number : 312530501185190475 as the sum of all permiter under 1 billion !
Can i Pm the code in order to found the error ?
Thanks so much !
User avatar
dawghaus4
Posts: 56
Joined: Fri Nov 29, 2013 2:22 am

Re: Problem 094

Post by dawghaus4 »

satyres wrote: Thanks for the reply !
i have found this number : 312530501185190475 as the sum of all permiter under 1 billion !
Can i Pm the code in order to found the error ?
Thanks so much !
You can, but I doubt if I would be able to resolve your issue. I am a beginning programmer, having started learning C++ in September of last year. If you are using another language, I probably couldn't follow it. I don't even know how well I could follow someone else's program written in C++. But I'd try.

With a sum that big, you must be adding lots of perimeters of triangles that don't meet the criteria. Since the largest possible perimeter is 1,000,000,000, you would have to have found tens of millions of triangles. I'm not sure I'm allowed to say how many triangles there are, but it is much, much fewer than that.
satyres
Posts: 31
Joined: Thu Feb 20, 2014 2:48 pm

Re: Problem 094

Post by satyres »

dawghaus4 wrote: You can, but I doubt if I would be able to resolve your issue. I am a beginning programmer, having started learning C++ in September of last year. If you are using another language, I probably couldn't follow it. I don't even know how well I could follow someone else's program written in C++. But I'd try.

With a sum that big, you must be adding lots of perimeters of triangles that don't meet the criteria. Since the largest possible perimeter is 1,000,000,000, you would have to have found tens of millions of triangles. I'm not sure I'm allowed to say how many triangles there are, but it is much, much fewer than that.
Thanks for your help ! problem solved i had a precision problem in double :? :?
paragnomen
Posts: 2
Joined: Sun Oct 05, 2014 11:53 pm

Re: Problem 094

Post by paragnomen »

Hi,
Could anyone explain me why triangles such as:
Expand
(92604733,92604733,92604734),
(185209465,185209465,185209464),
(194291787,194291787,194291788),
(253000835,253000835,253000836),
(286896519,286896519,286896518),
(311709883,311709883,311709884)
are invalid almost equilateral triangles?

Each triangle has integral sides, integral area and perimeter below one billion.
Other triangles are okay, but these not, especially 1st from above is strange - it comes up between
Expand
33895685
and
Expand
126500417
.
I'd be really grateful if someone would point me that mistake.
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: Problem 094

Post by Marcus_Andrews »

They do not have integral area.

For example, the first one has area 3713359590086716.71132486...
paragnomen
Posts: 2
Joined: Sun Oct 05, 2014 11:53 pm

Re: Problem 094

Post by paragnomen »

OK, I see... So my mistake was lack of precision in floating point numbers. Thanks for your help! :D
User avatar
Oliver1978
Posts: 166
Joined: Sat Nov 22, 2014 9:13 pm
Location: Erfurt, Germany

Re: Problem 094

Post by Oliver1978 »

satyres wrote:I have made an algorithm that show the correct answer but the sum of all permiter is incorrect ! ?
The number is really big and i'm using (unsigned long long) in C++ but it's wrong !
Those numbers are correct ?
12=5 5 6
120=17 17 16
1848=65 65 66
25080=241 241 240
351780=901 901 902
Thanks for the help!
I get completely different values. I guess satyres isn't mentioning perimeters but the area of the respective triangle. Assuming his n's are right, shouldn't the perimeters be like 16, 50, 196, 722, 2704, making this a total of 3688?
49.157.5694.1125
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 094

Post by hk »

See the post directly below the post you copied those data from.
I assume that calculating the perimeter of a triangle given the sides isn't rocket science for you.
If the given triangles are the ones you are looking for is something for you to find out.
Image
War ruins the life and health of untold numbers of innocent children.
Post Reply