Easy mathematic exercise [closed] - math

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Well, I have a little problem I want to solve.
We have two values. The first can go from 100 to 75. The second can go from 50 to 40.
How can I make it so when the first value is 100, the second is 50,
and when the first value is 75, the second is 40?
(For example 87.5 should be 45 on the second value)
I am trying to find that number.. Please give me the "formula" to do so.

Linear Interpolation
0.4 · Input + 10 = output
eg:
0.4 · 87.5 + 10 = 35 -10 = 45

number2 = ( ( (number1 - 75) / 25 ) * 10 ) + 40

Related

Finding two middle values in R? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
EDIT: the output is : [1] 49 65. Only allowed to use INDEXING. Code cannot be hard coded.
Can anyone please provide the code in R for finding two middle values in a vector with 10 elements?
The code would need to work for any vector size. so it cannot be hardcoded
The elements are 59,46,76,60,49,65,82,68,99,52
x <- c(59,46,76,60,49,65,82,68,99,52)
if(length(x)%%2 == 0) {
x[c(length(x)/2,(length(x)/2+1))]
} else{
x[ceiling(length(x)/2)]
}
[1] 49 65
Lets create a vector array with our values
array <- c(59,46,76,60,49,65,82,68,99,52)
From left to right, the middle two values of this array are the 5th and 6th
array[5:6]
# 49 65
If we want the numerically 5th and 6th highest number we can go with
sort(array)[5:6]
# 60 65
If you want to know which position of the original array the middle two elements are in, you can do
which(array %in% sort(array)[5:6])
# 4 6
You can expand the above programmatically for any array of even length by doing
n <- length(array)
x <- n/2
y <- x + 1
Then in any of the previous three examples, just replace 5 by x and 6 by y.
Like this ?
x <- c(59,46,76,60,49,65,82,68,99,52)
c(x[length(x)/2],x[length(x)/2 + 1])

Solving of algebra of the picture [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
i saw this picture over social network
put into equation that will be:
Given:
A=rabit
B=Dog
C=Cat
A+C=10
A+B=20
C+B=24
solve A+B+C = ?
some programming logic? what is your answer?
I do not see any programming logic in this, its just Math.
B + C = 24
-A-C = -20
Adding these two,
B-A = 4
Now taking the 1st equation,
A+B = 10
-A+B = 4
Adding both again
2B= 14
B = 7
Then, A = 3 ( from A+B = 10) and C = 17kgs (from B + C = 24)

How to do modulo calculation? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I'm following an online course and in one of the lecture it is said that add the first number with the second number modulo of 26.
I don't have the foggiest idea how to do it.
assume the first number 25 and the second number is 5. so how to add them along with modulo of 26 !!!
Modulo arithemtic means that you should use corresponding remainder, not the value itself.
In your case:
5 + 25 (mod 26) == 30 % 26 == 4 // <- "%" is taking remainder after dividing on 26
Whatever operation you do in mod 26, the answer will be in 0..25 range.
Sample code (C#):
int x = 5;
int y = 25;
int mod = 26;
int result = (x + y) % mod;

logstar function_the iterate of the natural logarithm_r [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In R, I would like to create a function that returns the smallest n such that the n-th repetition of the natural logarithm gives a value smaller than one. Ex.: fun(9182) = 3 because ln(ln(ln(9182))) = 0,793 < 1.
Any suggestions will be appreciated!
logstar<-function(x){if (x<1) 0 else 1 + logstar(log(x))}
#mrip's answer works well for single values. If you'd like a function that works for vectors, you'll want to use ifelse() rather than if:
> logstar <- function(x){ifelse(x<1,0,1 + logstar(ifelse(x<1,x,log(x))))}
> x = c(0.5,1,100,10000,1E8)
> logstar(x)
[1] 0 1 3 3 4
The ifelse() in the recursive call to logstar() prevents log() from generating NaN in some cases.

Differentiation Math Limits [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
limit x-->3 2x^2 + 7x-15/x-3
What i Simplified
Step 1 : 2x^2 + 10x -3x -15 / x-3
Step 2 : 2x( x + 5)-3( x + 5)/x-3
Step 3 : (2x - 3)(x + 5)/x-3
but unable to move further.. im thinking either the question ix wrong or there ix some trick which im unable to understand
thanx in advance
as x -> 3, the numerator goes to 3 * 8 = 24 and the denominator goes to 0, so the limit goes to +infinity if you approach 3 from the right, and -infinity if you approach 3 from the left
since you didn't specify which direction, the limit does not exist.
try graphing it: https://www.desmos.com/calculator

Resources