math

How do I get a, b and c, from a parabola given the vertex and two points?

馋奶兔 提交于 2020-05-17 06:14:54
问题 I would like to provide the vertex and two points for a parabola to find the a, b and c values. Goal The user input (the X value of the vertex) will always have a 'score' of 100 Background I read this article, which by the way, got me quite a bit further than what I was doing ... Thank You... but I think I misinterpreted the gist of the article. I was under the assumption that the vertex would be one of the three points - boy was I wrong. :-( How to calculate the vertex of a parabola given

Issue with large number [duplicate]

夙愿已清 提交于 2020-05-15 08:22:32
问题 This question already has answers here : Counting trailing zeros of numbers resulted from factorial (10 answers) Closed last month . I'm trying to count the number of trailing zero with a factorial. e.g 4! = 24 So you retrieve 0. 9! = 362880 So you retrieve 1. 10! = 9! x 10 = 3628800 So you retrieve 2. 11! = 10! x 11 = 3.99168E7 So you retrieve 2. static double factorial(double n) { double f = 1; for(int i = 1 ; i <= n ; i++) { f *= i; } return f; } static int numberOfZeros(double f) { int

ceil conterpart for Math.floorDiv in Java?

穿精又带淫゛_ 提交于 2020-05-12 12:25:55
问题 Is there any ceil counterpart for Math.floorDiv() How to calculate it fastest way with what we have? UPDATE The code for floorDiv() is follows: public static long floorDiv(long x, long y) { long r = x / y; // if the signs are different and modulo not zero, round down if ((x ^ y) < 0 && (r * y != x)) { r--; } return r; } Can we code ceil the similar way? UPDATE 2 I saw this answer https://stackoverflow.com/a/7446742/258483 but it seems to have too many unnecessary operations. 回答1: There is

ceil conterpart for Math.floorDiv in Java?

我与影子孤独终老i 提交于 2020-05-12 12:22:09
问题 Is there any ceil counterpart for Math.floorDiv() How to calculate it fastest way with what we have? UPDATE The code for floorDiv() is follows: public static long floorDiv(long x, long y) { long r = x / y; // if the signs are different and modulo not zero, round down if ((x ^ y) < 0 && (r * y != x)) { r--; } return r; } Can we code ceil the similar way? UPDATE 2 I saw this answer https://stackoverflow.com/a/7446742/258483 but it seems to have too many unnecessary operations. 回答1: There is

Apple Accelerate Framework scale and normalize a vector

浪子不回头ぞ 提交于 2020-05-12 02:48:58
问题 What functions can I use in Accelerate.framework to scale a vector by a scalar, and normalize a vector? I found one I think might work for scaling in the documentation but I am confused about it's operation. vDSP_vsma Vector scalar multiply and vector add; single precision. void vDSP_vsma ( const float *__vDSP_A, vDSP_Stride __vDSP_I, const float *__vDSP_B, const float *__vDSP_C, vDSP_Stride __vDSP_K, float *__vDSP_D, vDSP_Stride __vDSP_L, vDSP_Length __vDSP_N ); 回答1: The easiest way to

Inverse of math.atan2?

旧时模样 提交于 2020-05-11 04:12:48
问题 What is the inverse of the function math.atan2 I use this in Lua where I can get the inverse of math.atan by math.tan . But I am lost here. EDIT OK, let me give you more details. I needed to calculate angle between 2 points (x1,y1) and (x2,y2) and I did, local dy = y1-y2 local dx = x1-x2 local angle = atan2(dy,dx)* 180 / pi Now if I have the angle, is it possible to get back dy and dx? 回答1: Given only the angle you can only derive a unit vector pointing to (dx, dy) . To get the original (dx,

TypeError: '>' not supported between instances of 'list' and 'int'

两盒软妹~` 提交于 2020-05-11 03:50:07
问题 I'm working on a library for calculating certain values in a game. I have this code: million = [1000000, "M"] billion = [million * 1000, "B"] trillion = [billion * 1000, "T"] quadrillion = [trillion * 1000, "Qd"] quintillion = [quadrillion * 1000, "Qn"] sx = [quintillion * 1000, "Sx"] septillion = [sx * 1000, "Sp"] suffixes = [million, billion, trillion, quadrillion, quintillion, sx, septillion] def getSetupResult(orevalue, furnacemultiplier, *upgrades, **kwargs): for i in upgrades: orevalue

Logarithm Algorithm

折月煮酒 提交于 2020-05-09 18:17:47
问题 I need to evaluate a logarithm of any base, it does not matter, to some precision. Is there an algorithm for this? I program in Java, so I'm fine with Java code. How to find a binary logarithm very fast? (O(1) at best) might be able to answer my question, but I don't understand it. Can it be clarified? 回答1: Use this identity: log b (n) = log e (n) / log e (b) Where log can be a logarithm function in any base, n is the number and b is the base. For example, in Java this will find the base-2

Round to 25, 50, 75, 100

故事扮演 提交于 2020-05-09 16:30:10
问题 I'm not a Math person so I'm having a hard time to come up with a calculation to round the decimals to 25, 50, 75 and 100. And this will not be the typical round off because the decimals will not be decreased but only increased. Example: if 11.12, round to 11.25 if 11.34, round to 11.50 if 11.52, round to 11.75 if 11.76, round to 12.00 Here's my starting method: public float RoundNearestCents(String price) { float srp; return srp; } 回答1: public float RoundNearestCents(double d) { return

Round to 25, 50, 75, 100

拟墨画扇 提交于 2020-05-09 16:26:30
问题 I'm not a Math person so I'm having a hard time to come up with a calculation to round the decimals to 25, 50, 75 and 100. And this will not be the typical round off because the decimals will not be decreased but only increased. Example: if 11.12, round to 11.25 if 11.34, round to 11.50 if 11.52, round to 11.75 if 11.76, round to 12.00 Here's my starting method: public float RoundNearestCents(String price) { float srp; return srp; } 回答1: public float RoundNearestCents(double d) { return