Finding the opposite of a number in a 0 to 10 scale - math

This is probably something silly and simple in vectors or something, but I can't figure it out with my remedial Algebra. (Sorry for the initial confusion, I didn't fully explain this as I didn't think the 2nd half of my operation was relevant.)
I have a variable between 0 and 10. I want to find its opposite in that same scale, but I also want to change the "depth" of what that opposite means.
Variables:
X = User input variable between 0-10 (really 0-1.0)
Y = User input Depth between 0-10 (really 0-1.0)
Z = My result I'm looking for.
Example if my depth (Y) is Full (10), X would be:
X=0's opposite would be 10
X=1's opposite would be 9
X=2's opposite would be 8
etc..
Example if my depth (Y) is None (0), X would be:
X=0's opposite would be 0
X=1's opposite would be 1
X=2's opposite would be 2
etc..
I'm trying to accomplish this in Reaktor, a program for designing musical synthesizers. Specifically designing a "depth" parameter on a Chorus effect that inverts the left and right signal delay. So that the "rate" (X in this example) for the left signal is the opposite of the "rate" for the right signal, and the difference of how opposite they are is controlled by the "depth" (Y).

If x is your number, then what you're looking for is simply (10 - x).
edit One functional form that satisfies your updated spec is (x + y - (x * y) / 5.0). This is designed for values of x and y between 0 and 10.

X = 10 - Y where Y is input and X is output
0's opposite is 10: 10 = 10-0
1's opposite is 9: 9 = 10-1
2's opposite is 8: 8 = 10-2

Related

How to find the intecept x and y coordinates from 4 data points in Excel?

I have two points which form one line: (1,4) and (3,6), and another two which form another line: (2,1) and (4,2). These lines are continuous and I can find their intersection points by finding the equation for each line, and then equating them to find the x value at the intersection point, and then the y value.
i.e. for the first line, the equation is y = x + 3, and the second is y = 0.5x. At the intersection the y values are the same so x + 3 = 0.5x. So x = -6. Subbing this back into either of the equations gives a y value of -3.
From those steps, I now know that the intersection point is (-6,-3). The problem is I need to do the same steps in Excel, preferably as one formula. Can anyone give me some advice on how I would start this?
Its long but here it is:
Define x1,y1 and x2,y2 for the 1st line and x3,y3 and x4,y4 for the second.
x = (x2y1-x1y2)(x4-x3)-(x4y3-x3y4)(x2-x1) / [ (x2-x1)(y4-y3) - (x4-x3)(y2-y1) ]
y = (x2y1-x1y2)(y4-y3)-(x4y3-x3y4)(y2-y1) / [ (x2-x1)(y4-y3) - (x4-x3)(y2-y1) ]
Note that the denominators are the same. They will be ZERO! when the system has no solution. So you may want to check that in another cell and conditionally compute the answer.
Essentially, this formula is derived by solving a system of equations for x and y by hand using generic points (x1,y1), (x2,y2), (x3,y3), and (x4,y4). Easier yet, is solving the system by hand using well developed linear algebra concepts.
Wikipedia outlines this procedure well: Line-line intersection.
Also, this website describes all the different formulas and lets you put in whatever data you have in any mixed format and provides many details of the solutions: Everything about 2 lines.
Here's a matrix based solution:
x - y = -3
0.5*x - y = 0
Written as a matrix equation (I apologize for the poor typesetting):
| 1.0 -1.0 |{ x } { -3 }
| 0.5 -1.0 |{ y } = { 0 }
You can invert this matrix or use LU decomposition to solve it to get the answer. That method will work for any number of cases where you have one equation for each unknown.
This is easy to do by hand:
Subtract the second equation from the first: 0.5*x = -3
Divide both sides by 0.5: x = -6
Substitute this result into the other equation: y = 0.5*x = -3

How can you map a set of numbers, full of "holes" into a smaller one without "holes"

Can anyone figure out a function that can perform a mapping from a finite set of N numbers X = {x0, x1, x2, ..., xN} where each x can be valued 0 to 999999999 and N < 999999999, to a set Y = {0, 1, 2, 3, ..., N}.
In my case, i have about 24000000 element in the first set whose values can range as X. This elements have continuous block (for example 53000 to 1234500, then 8000000 to 9000000 and so on) and i have to remap this elements from 0 to 2400000. I don't require to maintain order.
I need a (possibly simple and rapid) math function, or a bitwise transformation, not something like put it ordered into an array and then binary search for their position.
Really thank to whom that can figure out a way to solve this!
Luca
If you don't want to keep some gigabytes of straight map, then augmented segment tree is reasonable approach. Tree should contain intervals and shift of every interval (sum of left intervals). Of course, finding appropriate interval (and shift) in this method is close to the binary search.
For example, you get X=80000015. Find interval for this value - it is 8000000 to 9000000. Rank of this interval is 175501 (1234500-53000 + 1). So X maps to
X => 175501 + 80000015 - 80000000 = 175516
For sparse elements make counting stage - find what is rank R for every number M and put (key=M, value=R) pair in hash table.
X = (3, 19, 20, 101)
table: [(3:0), (19:1), (20:2), (101:3)]
Note that one should keep balance between speed and space - for long filled intervals it is better to store only interval ends.

Stupidly simple algebra help for some programming

I'm coding a "wind" thing for a game where if you run a certain wind command, it blows people away in a radius around you.
x is the maximum distance a player can be from the wind source
y is the actual distance a player is from the source of the wind
z is some number between 0 and 10 where if the player is
right next to the wind source z would equal 0 and if
the player is 30 blocks away it would equal 10.
15 blocks away would make z = 5, etc.
x = 30
z = y / x * 10
all this works fine, but I need the z to be opposite. I need z to be 10 when the player is near and 0 when the player is at 30 blocks. 15 blocks away should be 5, etc
My math is failing me on how I can invert these numbers in an easy fashion
Does
z=(1-y/x)*10
work for you?

Finding 2 vectors knowing their cross product and one constraint

I have to find two vectors in 3D space, a and b such a x b = c where c is known. I also know one constraint, let's say that a_y = 0
So I have to look for these 2 vectors on (c_x)x+(c_y)y+(c_z)z=0 plane, for vector a I can simplify it to (c_x)x+(c_z)z=0
for vector b since it's perpendicular to a as well it has to be in intersection of (a_x)x+(a_z)z=0 plane and (c_x)x+(c_y)y+(c_z)z=0 plane. After adding cross product equation to that I have 4 equations and 5 unknowns (a_x,a_z,b_x,b_y,b_z). How can I solve this?
Thanks in advance.
EDIT: Maybe explaining what I need these for will help out somehow.
I have camera direction vector and I need vector that points to the right of screen, and second one that points up.
problem definition
A,B=?
C=!
Ay=!
A x B = C
implicated properties of dot and cross product due to perpendicularity:
(A.C) = 0
(B.C) = 0
|A|.|B| = |C|
set length for one of the vectors to any known constant like 1
|A|=1
|B|=|C|
This is also mentioned by John Moeller in his comment
Compute A
So length of |A|=1 and dot product of (A.C)=0 as they are perpendicular so:
Ax^2 + Ay^2 + Az^2 = 1
Ax.Cx + Ay.Cy + Az.Cz = 0
This is system of 2 equations and 2 unknowns so solve it. It will lead to 2 solutions chose one that is nonzero.
Compute B
We know that B is perpendicular to C so (B.C)=0 so put the constrains together:
A x B = C
Bx.Cx + By.Cy + Bz.Cz = 0
Bx^2 + By^2 + Bz^2 = Cx^2 + Cy^2 + Cz^2
If you expand the cross product you will get 5 equations and 3 unknowns. So solve the system (chose any 3 of the non trivial equations).
PS It seems this is to generate your NEH matrix analogy
So if that is the case all 3 vectors are perpendicular to each other while one points to specific direction (Up or North ...) and the sizes are usually 1 for all vectors.
So let assume D vector is the known aligning vector:
A'= C x D
B = C x A'
A = C x B
You can change the order of operands to obtain the directions you need. If the D is not known then you can use (1,0,0) or (0,1,0) or (0,0,1) instead chose one that is non parallel with C ... or have biggest (C.D). Also take a look at:
How to find view point coordinates?
[Notes]
dot product: (A.B)=Ax.Bx+Ay.By+Az.Cz
cross product: A x B
length: |A| = sqrt (Ax^2 + Ay^2 + Az^2)

Some help rendering the Mandelbrot set

I have been given some work to do with the fractal visualisation of the Mandelbrot set.
I'm not looking for a complete solution (naturally), I'm asking for help with regard to the orbits of complex numbers.
Say I have a given Complex number derived from a point on the complex plane. I now need to iterate over its orbit sequence and plot points according to whether the orbits increase by orders of magnitude or not.
How do I gather the orbits of a complex number? Any guidance is much appreciated (links etc). Any pointers on Math functions needed to test the orbit sequence e.g. Math.pow()
I'm using Java but that's not particularly relevant here.
Thanks again,
Alex
When you display the Mandelbrot set, you simply translate the real and imaginaty planes into x and y coordinates, respectively.
So, for example the complex number 4.5 + 0.27i translates into x = 4.5, y = 0.27.
The Mandelbrot set is all points where the equation Z = Z² + C never reaches a value where |Z| >= 2, but in practice you include all points where the value doesn't exceed 2 within a specific number of iterations, for example 1000. To get the colorful renderings that you usually see of the set, you assign different colors to points outside the set depending on how fast they reach the limit.
As it's complex numbers, the equation is actually Zr + Zi = (Zr + Zi)² + Cr + Ci. You would divide that into two equations, one for the real plane and one for the imaginary plane, and then it's just plain algebra. C is the coordinate of the point that you want to test, and the initial value of Z is zero.
Here's an image from my multi-threaded Mandelbrot generator :)
Actually the Mandelbrot set is the set of complex numbers for which the iteration converges.
So the only points in the Mandelbrot set are that big boring colour in the middle. and all of the pretty colours you see are doing nothing more than representing the rate at which points near the boundary (but the wrong side) spin off to infinity.
In mathspeak,
M = {c in C : lim (k -> inf) z_k = 0 } where z_0 = c, z_(k+1) = z_k^2 + c
ie pick any complex number c. Now to determine whether it is in the set, repeatedly iterate it z_0 = c, z_(k+1) = z_k^2 + c, and z_k will approach either zero or infinity. If its limit (as k tends to infinity) is zero, then it is in. Otherwise not.
It is possible to prove that once |z_k| > 2, it is not going to converge. This is a good exercise in optimisation: IIRC |Z_k|^2 > 2 is sufficient... either way, squaring up will save you the expensive sqrt() function.
Wolfram Mathworld has a nice site talking about the Mandelbrot set.
A Complex class will be most helpful.
Maybe an example like this will stimulate some thought. I wouldn't recommend using an Applet.
You have to know how to do add, subtract, multiply, divide, and power operations with complex numbers, in addition to functions like sine, cosine, exponential, etc. If you don't know those, I'd start there.
The book that I was taught from was Ruel V. Churchill "Complex Variables".
/d{def}def/u{dup}d[0 -185 u 0 300 u]concat/q 5e-3 d/m{mul}d/z{A u m B u
m}d/r{rlineto}d/X -2 q 1{d/Y -2 q 2{d/A 0 d/B 0 d 64 -1 1{/f exch d/B
A/A z sub X add d B 2 m m Y add d z add 4 gt{exit}if/f 64 d}for f 64 div
setgray X Y moveto 0 q neg u 0 0 q u 0 r r r r fill/Y}for/X}for showpage

Resources