Bots and Simulations > The Gene depository

Calculate ideal number of chloroplasts for a given light level

(1/1)

PhiNotPi:
Here is the line of code, which makes use of 2.46's new advanced "root" command.


--- Code: ---*.light 2 pow 3 root 2 pow 1386 mult 19601 div 32000 ceil
--- End code ---

The main difficulty of writing this was to make sure that the number stays within the limits of what DB can handle, which is integers +/- 2000000000.  This involved finding the best rational approximation for the fraction .

So far, the most accurate version of the code is the following, which is probably twice as accurate:


--- Code: ---*.light 39 3 pow mult 3 root 2 pow 39 div 2 pow 169 div 154 mult 19601 div 32000 ceil
--- End code ---

The simplest version is the following, but it has horrible accuracy:


--- Code: ---*.light 3 root 4 pow dup pyth 20 div 32000 ceil
--- End code ---


Also, the following gives the maximum number of chloroplasts for a given light level.  Any more chloroplasts, and you will actually lose more energy than you make.


--- Code: ---*.light 2 pow 3 root 2 pow 510 mult 3361 div 32000 ceil
--- End code ---

All of these have some rounding issues, mainly due to the 3 root. I tested it and they are generally accurate to within a few percent. 

Navigation

[0] Message Index

Go to full version