math

Find null points of sinus function

余生长醉 提交于 2020-01-14 06:16:52
问题 I want to implement a function in java that finds the null points of the sinus function. I know how to do that but I do not really understand the following definition of that problem: Implement a function that searches for null points in the sinus function in a interval between a and b. The search-interval[lower limit, upper limit] should be halved until lower limit and upper limit are less then 0.0001 away from each other. Why halving the interval? Any ideas? 回答1: Sounds like you are being

Avoiding interger overflow with permutation (nPr, nCr) functions in C

ⅰ亾dé卋堺 提交于 2020-01-14 06:14:48
问题 I am attempting to do some statistics-related functions so I can carry out a few related procedures (ie: statistics calculations for probabilities, generate Pascal's triangle for an arbitrary depth, etc). I have encountered an issue where I am likely dealing with overflow. For example, if I want to calculate nPr for (n=30,p=1), I know that I can reduce it to: 30P1 = 30! / (30 - 1)! = 30! / (29)! = 30! / 29! = 30 However, when calculating using the functions below, it looks like I will always

Avoiding interger overflow with permutation (nPr, nCr) functions in C

荒凉一梦 提交于 2020-01-14 06:14:24
问题 I am attempting to do some statistics-related functions so I can carry out a few related procedures (ie: statistics calculations for probabilities, generate Pascal's triangle for an arbitrary depth, etc). I have encountered an issue where I am likely dealing with overflow. For example, if I want to calculate nPr for (n=30,p=1), I know that I can reduce it to: 30P1 = 30! / (30 - 1)! = 30! / (29)! = 30! / 29! = 30 However, when calculating using the functions below, it looks like I will always

Avoiding interger overflow with permutation (nPr, nCr) functions in C

扶醉桌前 提交于 2020-01-14 06:14:07
问题 I am attempting to do some statistics-related functions so I can carry out a few related procedures (ie: statistics calculations for probabilities, generate Pascal's triangle for an arbitrary depth, etc). I have encountered an issue where I am likely dealing with overflow. For example, if I want to calculate nPr for (n=30,p=1), I know that I can reduce it to: 30P1 = 30! / (30 - 1)! = 30! / (29)! = 30! / 29! = 30 However, when calculating using the functions below, it looks like I will always

iPhone SDK Present Value function

核能气质少年 提交于 2020-01-14 05:45:27
问题 Present value is the value on a given date of a future payment or series of future payments, discounted to reflect the time value of money and other factors such as investment risk. Present value calculations are widely used in business and economics to provide a means to compare cash flows at different times on a meaningful "like to like" basis. http://en.wikipedia.org/wiki/Present_value What would be the best way to tackle this in an Objective-C function? double retire62 = [benefit62.text

Using Swift, how can I determine if a coordinates ordered pair (x,y) is within the bounds of n ordered pairs?

橙三吉。 提交于 2020-01-14 04:41:07
问题 Is there a math function of some kind in Swift (or maybe multiple functions that work together), where I can create sets of ordered pair coordinates, and then pass in a single ordered pair coordinate to get a bool true/false of whether it's within the bounds of the set? I'm not the greatest at math, so I'm hoping someone who is (and understands how to solve this problem in Swift) can help me out here. Example data: I have a coordinate where someone is located in lat-long. Let's say (28

Find out which combination of numbers in set add up to a given tơtal?

核能气质少年 提交于 2020-01-14 04:08:39
问题 I have set of numbers; example: [12, 13, 15, 18] . From which I have to find the elements whose sum is a specific "total value", for example: 25 is 12 + 13. Edit: First of all thank you all for your valuable feedback but i think many of you misunderstood my question! My question is not just for "two combination" but for more than two. For example: 1 2 3 4 5 6 7 8 9 10 100 From the above list we need to get "119" here we need more than "two combination". How can i write the code through bash

Perfect Square in Leetcode

て烟熏妆下的殇ゞ 提交于 2020-01-14 03:24:20
问题 I am having trouble understanding one of a Leetcode Problem. Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return 2 because 13 = 4 + 9. Solution: int numSquares(int n) { static vector<int> dp {0}; while (dp.size() <= n) { int m = dp.size(), squares = INT_MAX; for (int i=1; i*i<=m; ++i) squares = min(squares, dp[m-i*i] + 1); dp.push_back

interpolate number sequence

…衆ロ難τιáo~ 提交于 2020-01-14 02:31:11
问题 I am trying to complete an uncomplete list of numbers, I couldn't find any pythonic way to do it. I have a sequence of days from 1 to 31, and for each day, I have a float value. #dictionnary{day: value} monthvalues = {1: 1.12, 2: 3.24, 3: 2.23, 5: 2.10, 7: 4.97} etc.. to 31st day but my data is uncomplete, and some days are missing! therefore I want to fill the missing picture mathematically this way: sample month1: {16: 2.00, 18: 4.00} #==> I want to add to the dictionnary 17: 3.00 sample

How to move point along circle?

一曲冷凌霜 提交于 2020-01-13 19:46:20
问题 I want to move a sprite in a circular motion by using a circle radius and movingangle. I know for instance that the sprite is moving in a circle with the radius 10 and It's current position is (387,38) and angle is 28 degrees. Now I wann't move it say, 100px along the circle perimeter. p1 = x&y coordinate, known (387,38) in example with movingangle 28 degrees r = radius, known (10 in example) l = distance to move along bend, known (100px in example) p2 = new point, what is this x and y value?