The following problem has been puzzling me for a couple of days (nb: this is not homework).
There exists two geometric sequences that sum to 9. The value of their second term (t2) is 2.
Find the common ratio (r)
Find the first element (t1) of each
The answers to (1) are 2/3 and 1/3 and the answers to (2) are 3 and 6 respectively. Unfortunately, I can't understand how these were derived.
In tackling (1) I've tried to apply algebraic substitution to solve for r as follows:
t2 = t1*r; since t2 = 2 we have:
t1 = 2/r
The equation for calculating the sum (S) of a sequence that converges to a limit is given by:
S = t1 / (1 - r)
So, I tried to plug my value of t1 into S and solve for r as follows:
9 = (2/r) / (1-r)
9(1-r) = 2/r
2/9 = r(1-r)
Unfortunately, from this point I get stuck. I need to eliminate one of the r's but I can't seem to be able to.
Next, I thought to solve for r using the formula that sums the first 2 terms (S2) of the sequence:
S2 = (t1 (1-r^2)) / (1-r)
t1 + 2 = (t1 (1-r^2)) / (1-r)
but expanding this out I again run into the same problem (can't eliminate one of the r's).
So I have 2 questions:
What am I doing wrong when deriving r?
Once I have one of its values, how I derive the other?
2/9 = r(1-r)
Unfortunately, from this point I get
stuck. I need to eliminate one of the
r's but I can't seem to be able to.
You need to learn to factorise!
2/9 = r(1-r)
2/9 = r - r^2
2 = 9r - 9r^2
9r^2 - 9r + 2 = 0
(3r)^2 - 3(3r) + 2 = 0
to make it easier, let R = 3r
R^2 - 3R + 2 = 0
(R - 1)(R - 2) = 0
so 3r - 1 = 0, or 3r - 2 = 0
i.e. r = 1/3 or r = 2/3.
And your first term is 2/(1/3) = 6, or 2/(2/3) = 3
QED!
2/9 = r (1 - r)
Rewrite this as ax2 + bx + c and use the quadratic formula to solve it:
2/9 = r - r2
r2 - r + 2/9 = 0
Using the quadratic formula, the roots are:
[-1 ± √(1 - 8/9)] / 2
= (1 ± 1/3) / 2
= 1/2 ± 1/6
= 1/3 or 2/3
Edit: Aw shoot, I spent way too long figuring out how to write plus/minus and square root. :-P
Related
I working on computer vision task and have this equation:
R0*c + t0 = R1*c + t1 = Ri*c + ti = ... = Rn*c + tn ,
n is about 20 (but can be more if needs)
where each pair of R,t (rotation matrix and translation vector in 3D) is a result of i-measurement and they are known, and vector c is what I whant to know.
I've got result with ceres solver. It's good that it can handle outliers but I think it's overkill for this task.
So what methods I should use for two situations:
With outliers
Without outliers
To handle outliers you can use RANSAC:
* In each iteration randomly pick i,j (a "sample") and solve c:
Ri*c + ti = Rj*c + tj
- Set Y = Ri*c + ti
* Apply to a larger population:
- Select S={k} for which ||Rk*c + tk - Y||<e
e ~ 3*RMS of errors without outliers
- Find optimal c for all k equations (with least mean square)
- Give it a "grade": size of S
* After few iterations use optimal c found for Max "grade".
* Number of iterations: log(1-p)/log(1-w^2)
[https://en.wikipedia.org/wiki/Random_sample_consensus]
p = 0.001 (for example. It is the required certainty of the result)
w is an assumption of nonoutliers/n.
I want to get nth term of the sequence of binary numbers with only two set bits in increasing order
(11,101,110,1001,1010,1100,10001,10010,10100,11000....).
I figured out it can be formed with string manipulation if I know the nth term of this series below:
(2,3,3,4,4,4,5,5,5,5,6,6,6,6,6.....).
Can someone help me with how to get nth term of series:
(2,3,3,4,4,4,5,5,5,5,6,6,6,6,6.....)
Edit: please focus to get the nth term of series only (2,3,3,4,4,4,5,5,5,5,6,6,6,6,6.....). I have other parts figured out.
This is series A003057 at oeis.org.
There are several formulae that can be used to calculate the nth value. The simplest appears to be as follows:
a(n) = ceiling((sqrt(8n-7)+1)/2)
There are C(N,1)=N combinations of length N, starting with 1 and containing 2 ones.
So you have one 2, two 3s, three fours and so on - note arithmetic progression. Another point of view: we can see the first
2: at the 1st place
3: 2nd
4: 4th
5: 7
6: 11
k: (k-1)*(k-2)/2 + 1 //from arithmetic progression sum formula
So solve quadratic equation
N = (k-1) * (k-2) / 2 + 1
or
k^2 - 3 * k + 4 - 2 * N = 0
for unknown k - find positive root floored down to integer and you will get k as number at the n-th place in sequence
D = 9 - 16 + 8 * N = 8*N - 7
k = Floor((3 + Sqrt(8*N - 7)) / 2)
example: for N=7 k = (3+Sqrt(56-7))/2 = 5
for N=10 k = Floor(3+Sqrt(80-7))/2 = Floor(5.77) = 5
I am very new to R, trying to use it to visualize things. To make the story short, I'm exploring a conjecture I have on the economic theory of public goods. (I'm in my mid 50s, so bear with me.)
As far as R is concerned, I need to create a matrix with two vectors, one with E(W)/max(W), and the 2nd vector with stdev(W)/E(W). The trick is that the sample space of W, my r.v., keeps expanding by 1. To make this clearer, here's the probability distribution of W, the first 4 iterations:
W p
0 2/3
1 1/3
W p
0 3/6
1 2/6
2 1/6
W p
0 4/10
1 3/10
2 2/10
3 1/10
W p
0 5/15
1 4/15
2 3/15
3 2/15
4 1/15
...
I need to iterate this 20 times or so. Of course, I could do this manually, by copying, pasting, and then manually adjusting simple code, but it'd be too bulky and ugly looking, and I'm a bit concerned about --- you know --- elegance.
With good help from this community, I learned how to program R to generate the denominator of the probabilities:
R code iteration
I thought (foolishly) I could take it from there, but after a few hours scratching my bald head, I'm still stuck without knowing how to get what I want. It's about my not understanding well how to program less simple procedures that iterate. :/
I'll appreciate any help, especially clues setting me on the right track.
Thanks in advance!
You're just diving out by the sum; and sum of 1 to k is k*(k+1)/2. So...
R>k <- 3
R>k:1 / (k^2 + k)*2
I assume you mean that you want a matrix of 20 or so rows with each row being the values of your two requested quantities given that the distribution has max(W) = N values.
t(vapply(seq_len(20) + 1, function(N) {
W <- seq(N, 1) / (N * (N + 1) / 2) # create your distribution w/ 20 values
E <- function(pdf) sum((seq_along(pdf) - 1) * pdf)
c(E(W) / max(W), sqrt(E((W - E(W))^2)) / E(W))
}, numeric(2)))
I am trying to replicate a graph on an example on Danish Data set used in the text Non-Life Insurance Mathematics.
I want to create the following new variable from my data set so I can plot the graph. My biggest challenge is how to sum(sigma) over w over j given that I have to start from max of two values to min of two values. I don't have the faintest idea how to do it in R. Guess I have a lot to still learn in how to do operations in R.
I would appreciate if some how can give me useful tip on how to go about it.
Below is the equation in question I couldn't replace the sigma sign so I used the literally interpretation (sum)
1/λ(i)) = 1/(2m + 1) * sum Wj from {j=max(1,i−m) to min(n,i+m)} for m = 50.
Try this
m = 50
total = 0
for (j in seq(max(1, i-m), min(n, i+m)) {
total = total + W[j]
}
total = total / (2 * m + 1)
lambda = 1 / total
or this
m = 50
lambda = 1 / (sum(W[max(i,i-m) : min(n,i+m)]) / (2 * m + 1))
I have a linear scale that ranges form 0.1 to 10 with increments of change at 0.1:
|----------[]----------|
0.1 5.0 10
However, the output really needs to be:
|----------[]----------|
0.1 1.0 10 (logarithmic scale)
I'm trying to figure out the formula needed to convert the 5 (for example) to 1.0.
Consequently, if the dial was shifted halfway between 1.0 and 10 (real value on linear scale being 7.5), what would the resulting logarithmic value be? Been thinking about this for hours, but I have not worked with this type of math in quite a few years, so I am really lost. I understand the basic concept of log10X = 10y, but that's pretty much it.
The psuedo-value of 5.0 would become 10 (or 101) while the psuedo-value of 10 would be 1010. So how to figure the pseudo-value and resulting logarithmic value of, let's say, the 7.5?
Let me know if addition information is needed.
Thanks for any help provided; this has beaten me.
Notation
As is the convention both in mathematics and programming, the "log" function is taken to be base-e. The "exp" function is the exponential function. Remember that these functions are inverses we take the functions as:
exp : ℝ → ℝ+, and
log : ℝ+ → ℝ.
Solution
You're just solving a simple equation here:
y = a exp bx
Solve for a and b passing through the points x=0.1, y=0.1 and x=10, y=10.
Observe that the ratio y1/y2 is given by:
y1/y2 = (a exp bx1) / (a exp bx2) = exp b(x1-x2)
Which allows you to solve for b
b = log (y1/y2) / (x1-x2)
The rest is easy.
b = log (10 / 0.1) / (10 - 0.1) = 20/99 log 10 ≈ 0.46516870565536284
a = y1 / exp bx1 ≈ 0.09545484566618341
More About Notation
In your career you will find people who use the convention that the log function uses base e, base 10, and even base 2. This does not mean that anybody is right or wrong. It is simply a notational convention and everybody is free to use the notational convention that they prefer.
The convention in both mathematics and computer programming is to use base e logarithm, and using base e simplifies notation in this case, which is why I chose it. It is not the same as the convention used by calculators such as the one provided by Google and your TI-84, but then again, calculators are for engineers, and engineers use different notation than mathematicians and programmers.
The following programming languages include a base-e log function in the standard library.
C log() (and C++, by inclusion)
Java Math.log()
JavaScript Math.log()
Python math.log() (including Numpy)
Fortran log()
C#, Math.Log()
R
Maxima (strictly speaking a CAS, not a language)
Scheme's log
Lisp's log
In fact, I cannot think of a single programming language where log() is anything other than the base-e logarithm. I'm sure such a programming language exists.
I realize this answer is six years too late, but it might help someone else.
Given a linear scale whose values range from x0 to x1, and a logarithmic scale whose values range from y0 to y1, the mapping between x and y (in either direction) is given by the relationship shown in equation 1:
x - x0 log(y) - log(y0)
------- = ----------------- (1)
x1 - x0 log(y1) - log(y0)
where,
x0 < x1
{ x | x0 <= x <= x1 }
y0 < y1
{ y | y0 <= y <= y1 }
y1/y0 != 1 ; i.e., log(y1) - log(y0) != 0
y0, y1, y != 0
EXAMPLE 1
The values on the linear x-axis range from 10 to 12, and the values on the logarithmic y-axis range from 300 to 3000. Given y=1000, what is x?
Rearranging equation 1 to solve for 'x' yields,
log(y) - log(y0)
x = (x1 - x0) * ----------------- + x0
log(y1) - log(y0)
log(1000) - log(300)
= (12 - 10) * -------------------- + 10
log(3000) - log(300)
≈ 11
EXAMPLE 2
Given the values in your question, the values on the linear x-axis range from 0.1 to 10, and the values on the logarithmic y-axis range from 0.1 to 10, and the log base is 10. Given x=7.5, what is y?
Rearranging equation 1 to solve for 'y' yields,
x - x0
log(y) = ------- * (log(y1) - log(y0)) + log(y0)
x1 - x0
/ x - x0 \
y = 10^| ------- * (log(y1) - log(y0)) + log(y0) |
\ x1 - x0 /
/ 7.5 - 0.1 \
= 10^| --------- * (log(10) - log(0.1)) + log(0.1) |
\ 10 - 0.1 /
/ 7.5 - 0.1 \
= 10^| --------- * (1 - (-1)) + (-1) |
\ 10 - 0.1 /
≈ 3.13
:: EDIT (11 Oct 2020) ::
For what it's worth, the number base 'n' can be any real-valued positive number. The examples above use logarithm base 10, but the logarithm base could be 2, 13, e, pi, etc. Here's a spreadsheet I created that performs the calculations for any real-valued positive number base. The "solution" cells are colored yellow and have thick borders. In these figures, I picked at random the logarithm base n=13—i.e., z = log13(y).
Figure 1. Spreadsheet values.
Figure 2. Spreadsheet formulas.
Figure 3. Mapping of X and Y values.