JohnCarter Posted July 23, 2013 Share Posted July 23, 2013 The idea I want to do based on this logarithm http://www.wolframalpha.com/input/?i...100+log%28x%29 Basically the idea is, have a linear progression of reps (+1 power per 100 reps you have), until that line intersects (around 640~), then it would follow the curve, which would reduce the progression of rep power. My problem is translating that into php Link to comment https://forums.phpfreaks.com/topic/280417-help-needed/ Share on other sites More sharing options...
Muddy_Funster Posted July 23, 2013 Share Posted July 23, 2013 your link doesn't work, and your information is a little sparse. Is this a php coding quertion or a php math question? Link to comment https://forums.phpfreaks.com/topic/280417-help-needed/#findComment-1441771 Share on other sites More sharing options...
JohnCarter Posted July 23, 2013 Author Share Posted July 23, 2013 your link doesn't work, and your information is a little sparse. Is this a php coding quertion or a php math question? Oh I'm sorry I fixed the link http://www.wolframalpha.com/input/?i=x+%3D+100+log%28x%29 My problem is translating that into php. there's a natural logarithm function built in http://us3.php.net/log still at a loss how to apply the curve. Link to comment https://forums.phpfreaks.com/topic/280417-help-needed/#findComment-1441797 Share on other sites More sharing options...
Muddy_Funster Posted July 23, 2013 Share Posted July 23, 2013 So does something like the following help? for($i=1;$i<=700;$i++){ $rawLog= log($i); $roundedLog = round($x, 2); $roundedLogOneHundred = $y * 100; if($roundedLogOneHundred == $i){ echo $roundedLogOneHundred." - ".$i." <<<--- This one!!<br>"; } else{ echo $roundedLogOneHundred." - ".$i."<br>"; } } Link to comment https://forums.phpfreaks.com/topic/280417-help-needed/#findComment-1441799 Share on other sites More sharing options...
Psycho Posted July 23, 2013 Share Posted July 23, 2013 I'm not sure what X represents in your example: the reps or reps/100 (i.e. "+1 power per 100 reps you have"). I think it is the latter. So, the simplest solution would be something like this: function getPower($reps) { $divVal = $reps/100; $logVal = max(100 * log($divVal), 1); //Max is needed to prevent 0 being returned @ 100 reps return min($divVal, $logVal); } //Test loop for($rep=1; $rep<800; $rep++) { $reps = $rep * 100; $power = getPower($reps); echo "Reps: {$reps}, Power: {$power}<br>\n"; } Here is the part of the output from the test loop where you can see the transition take place: Reps: 64500, Power: 645 Reps: 64600, Power: 646 Reps: 64700, Power: 647 Reps: 64800, Power: 647.389069635 Reps: 64900, Power: 647.54327167 Reps: 65000, Power: 647.697236289 Link to comment https://forums.phpfreaks.com/topic/280417-help-needed/#findComment-1441801 Share on other sites More sharing options...
JohnCarter Posted July 23, 2013 Author Share Posted July 23, 2013 I'm not sure what X represents in your example: the reps or reps/100 (i.e. "+1 power per 100 reps you have"). I think it is the latter. So, the simplest solution would be something like this: function getPower($reps) { $divVal = $reps/100; $logVal = max(100 * log($divVal), 1); //Max is needed to prevent 0 being returned @ 100 reps return min($divVal, $logVal); } //Test loop for($rep=1; $rep<800; $rep++) { $reps = $rep * 100; $power = getPower($reps); echo "Reps: {$reps}, Power: {$power}<br>\n"; } Here is the part of the output from the test loop where you can see the transition take place: Reps: 64500, Power: 645 Reps: 64600, Power: 646 Reps: 64700, Power: 647 Reps: 64800, Power: 647.389069635 Reps: 64900, Power: 647.54327167 Reps: 65000, Power: 647.697236289 Thanks for this, I will test it out later. Link to comment https://forums.phpfreaks.com/topic/280417-help-needed/#findComment-1441860 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.