Formula for the perfect breakfast egg :-)

Share your advanced PureBasic knowledge/code with the community.
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Formula for the perfect breakfast egg :-)

Post by Little John »

Image

Code: Select all

; PB 5.41

EnableExplicit

Procedure.d EggCookingTime (d.i, t_initial.i, soft.i=#True, elevation.i=0)
   ; -- Note: The egg must be put into *boiling* water!
   ; in : d        : small diameter      of the egg [mm]
   ;      t_initial: initial temperature of the egg [°C]
   ;      soft     : #True / #False
   ;      elevation: elevation above sea level [m]
   ; out: return value: time needed for cooking the egg [minutes],
   ;                    or 0 on error
   ;
   ; [modified after
   ;  Gruber, Werner (2008):
   ;  Unglaublich einfach - einfach unglaublich. Physik für jeden Tag.
   ;  München: Heyne
   ;  pp. 207-209]
   Protected t_water.d, r.d, t_inside.i
   
   t_water = 100 - 0.0033 * elevation  ; temperature of boiling water at the given elevation
   If t_water <= 82.0
      ProcedureReturn 0   ; At an elevation of about 5500 m or higher, 
   EndIf                  ; boiling water is not hot enough for cooking eggs.
   
   If soft
      t_inside = 62
   Else
      t_inside = 82
   EndIf
   r = 2 * (t_water - t_initial) / (t_water - t_inside)
   
   ProcedureReturn 0.0016 * d * d * Log(r)
EndProcedure


; -- Demo
Define d.i, t_s.d, min_s.i, sec_s.s, t_h.d, min_h.i, sec_h.s

Macro ShowTable (_t_initial_)
   Debug "Egg " + _t_initial_ + " °C"
   Debug ""
   Debug "       |  soft   |  hard"
   Debug "d [mm] | min:sec | min:sec"
   Debug "-------+---------+--------"
   
   For d = 35 To 50 Step 5
      t_s = EggCookingTime(d, _t_initial_, #True)
      min_s = Int(t_s)
      sec_s = Str(Int((t_s-min_s)*60.0))
      
      t_h = EggCookingTime(d, _t_initial_, #False)
      min_h = Int(t_h)
      sec_h = Str(Int((t_h-min_h)*60.0))
      
      Debug "   " + d + "  |   " + min_s + ":" + RSet(sec_s, 2, "0") + "  |   " + min_h + ":" + RSet(sec_h, 2, "0")
   Next
   Debug ""
   Debug ""
EndMacro


Debug "Time needed for cooking eggs at sea level"
Debug ""
ShowTable( 4)   ; refrigerator temperature
ShowTable(20)   ; room temperature
Bon appétit! :-)
Last edited by Little John on Sat Jan 16, 2016 10:08 am, edited 2 times in total.
infratec
Always Here
Always Here
Posts: 7620
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Formula for the perfect breakfast egg :-)

Post by infratec »

Hi,

have you cross-checked all points of the tables :?:

:mrgreen: :mrgreen: :mrgreen:
sys64802
Enthusiast
Enthusiast
Posts: 105
Joined: Sat Sep 12, 2015 6:55 pm

Re: Formula for the perfect breakfast egg :-)

Post by sys64802 »

Nice ;-)

It would require another param: height above sea level, since lower pressure make the water boil at lower temperature.
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Formula for the perfect breakfast egg :-)

Post by Little John »

sys64802 wrote:It would require another param: height above sea level, since lower pressure make the water boil at lower temperature.
You are absolutely right. The protected variable t_water must be adapted accordingly (or the code can be changed, so that t_water is a parameter of the procedure).

According to this source (German), for instance at a height of 2000 meters above sea level water boils already at 93 °C. If in doubt, everyone can easily measure her/himself the temperature of boiling water at her/his location.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Formula for the perfect breakfast egg :-)

Post by Keya »

The Perfect Egg v2.0 - now with Mt Everest support!
http://study.com/academy/lesson/how-to- ... point.html

Code: Select all

BoilingPointF˚ = 212˚ - (0.00184)h    ;h is altitude (feet).  Everest: 29,029ft BP=71˚C/160˚F
The IUPAC recommended standard boiling point of water at a standard pressure of 100 kPa (1 bar) is 99.61 °C (211.3 °F). For comparison, on top of Mount Everest, at 8,848 m (29,029 ft) elevation, the pressure is about 34 kPa (255 Torr) and the boiling point of water is 71 °C (160 °F). - https://en.wikipedia.org/wiki/Boiling_point
https://en.wikipedia.org/wiki/List_of_c ... _elevation
UK = 162 m (531 ft)
USA = 760 m (2,493 ft)
Nepal = 2,565 m (8,415 ft)
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Formula for the perfect breakfast egg :-)

Post by Little John »

Keya wrote:http://study.com/academy/lesson/how-to- ... point.html

Code: Select all

BoilingPointF˚ = 212˚ - (0.00184)h    ;h is altitude (feet).
Thanks for the hint!
I've change the above code, so that it takes the elevation above sea level into account.
https://en.wikipedia.org/wiki/List_of_c ... _elevation
UK = 162 m (531 ft)
USA = 760 m (2,493 ft)
Nepal = 2,565 m (8,415 ft)
Sorry, but this is very misleading. What matters here is the real elevation of the location where you are cooking the egg, not the average elevation of the country where you are.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Formula for the perfect breakfast egg :-)

Post by Keya »

misleading? it says "List_of_countries_by_average_elevation" in the URL! I only added it for comparison to Everest - of course everyone knows you need your actual elevation not your country average :) Anyway nice update, now everyone on the planet can boil a perfect egg including our crazy friends at Base Camp heehee :D
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Formula for the perfect breakfast egg :-)

Post by Little John »

Keya wrote:misleading?
Yes.
You've got a PM.
Post Reply