How can I make this work? (Please Help)

Discussion in 'Programming/Html' started by rakee18, Jul 13, 2015.

  1. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    fdfsdf
     
    Last edited: Jul 14, 2015
  2. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    please help
     
  3. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    In case the growth is increasing from the start and at some point starts to decrease you declare the var outside of the loop like
    int maxGrowth = 0;
    and at each iteration of loop compare this var with current growth. In case current growth is greater than maxGrowth you save current one into maxGrowth. Else in case maxGrowth is greater than current one the population has started to decrease and maxGrowth contains the maximum.
     
  4. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Btw, your function is in trouble:

    because n == 0 (always) - hence the loop will not iterate at all and function will always return 0.
    Also are you sure the t needs to be incremented twice per each loop iteration - in for() and in loop body?

    And in function growth you did not initialize var growth:

    and in case temp == 37 which value will be in growth?
     
    Last edited: Jul 14, 2015

  5. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    Yes I took the loop out of the function.
     
  6. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Function to calculate the rate of change of the k

    Initial value for the k is 0.1

    And with every generation k will be icreased by the value calculated in calculate_k_rate().

    Initial number of bacterias in population No is 1.
     
    Last edited: Jul 14, 2015
  7. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    Thanks. Can you tell me how can i get the max population?
     
  8. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    So the loop should look like:

    Because No is equal to 1 we can omit it -> N = e ^ ((1-k) * t)

    And loop is iterated while N > 0 becase N == 0 means the population is dead.

    The total time of population`s life equals to t * 20 (minutes).

    Edit: Updated the code to create the t outside the loop because not all compilers let to use the variable created in the for() outside the loop.
     
    Last edited: Jul 14, 2015
  9. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    Im getting an error for loop intial declaration in c99 mode.
     
  10. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Paste it here
     

  11. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    hggfdg
     
    Last edited: Jul 14, 2015
  12. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Function total() returns not the maximum of population but the number of the generation with maximum population.

    You can print the maxN and maxT and t inside the total() (after the loop).

    Also you can print the value of rate inside calculate_k_rate().
     
    Last edited: Jul 13, 2015
  13. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    oh okay.
     
  14. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    My error - here is revised code

    For con==8 and nut==3 and cel==37 it should return 0.005.
     
    Last edited: Jul 14, 2015
  15. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Alternative variant - with abs()
     
    Last edited: Jul 14, 2015

  16. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    Yes calculate for k is okay but I think theres something wrong with the maxT maxN function. max t is 42 instead of 41 and n is 0.0000
     
  17. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    Place the whole code again (or change the post with the old one).
     
  18. rakee18

    rakee18 Guest

    Messages:
    52
    Likes Received:
    0
    GPU:
    Asus GTX 580 Matrix
    Thanks
     
    Last edited: Jul 14, 2015
  19. mbk1969

    mbk1969 Ancient Guru

    Messages:
    15,543
    Likes Received:
    13,561
    GPU:
    GF RTX 4070
    I have changed the time from hours to minutes.
     
    Last edited: Jul 14, 2015

Share This Page