Inverse of a particular function

Hi, I should get the inverse of this function, expressing v in dependence of x, y.
y = x * cos(norm(v)) + v * sin (norm(v))/norm(v);
Could you write here the Matlab code, if it's possible?

Answers (2)

It is possible to solve your equation for v explicitly. However, it should be understood that if any solutions exist, there will always be infinitely many of them. The vectors x, y, and v can have any number of elements, though these should all three be the same.
% The problem: Given vectors x and y, find vector v such that
% y = x*cos(*norm(v))+v/norm(v)*sin(norm(v))
p = norm(x);
i = x/p; % Unit vector in vector x direction
r = dot(x,y)/p; % Component of y in x direction
j = y-r*i;
s = norm(j); % Component of y orthogonal to x
j = j/s; % Unit vector in plane of x & y, orthogonal to vector x
% v must be in the plane containing vectors x and y
% and can therefore be expressed as:
% v = u*(cos(t)*i+sin(t)*j)
% for some scalars, t and u.
% The original vector equation can therefore be
% expressed as the solution to two scalar equations
% in two scalar unknowns, t and u, given the
% values r, s, and p:
% r = p*cos(u) + cos(t)*sin(u)
% s = sin(t)*sin(u)
%
% For a solution to exist, r and s must lie within
% the ellipse r^2/(p^2+1)+s^2 < 1
if r^2/(p^2+1)+s^2 >= 1, fprintf('No solutions exist\n'), else
% It can be shown that we can find four solutions for t and u as follows:
q = atan2(r^2-p^2-s^2,2*r*s);
a = asin((r^2-p^2+s^2+2*p^2*s^2)/sqrt((r^2-p^2-s^2)^2+(2*r*s)^2));
t = mod([(a-q)/2,(a-q)/2+pi,(pi-a-q)/2,(-pi-a-q)/2],2*pi);
% The corresponding solutions for u are:
u = mod(atan2(s./sin(t),(r*sin(t)-s*cos(t))./(p*sin(t))),2*pi);
end
Each of these t,u pairs defines a solution vector, v:
v = u*(cos(t)*i+sin(t)*j)
Also infinitely many other solutions for v can be found by adding arbitrary positive multiples of 2*pi to u for each of the above four solutions.

1 Comment

Added note: The "elliptical" inequality, r^2/(p^2+1)+s^2 <= 1, follows from the necessary equality
sin(2*t+q) = (r^2-p^2+s^2+2*p^2*s^2)/sqrt((r^2-p^2-s^2)^2+(2*r*s)^2)
by requiring that sin(2*t+q)^2 <= 1.

Sign in to comment.

John D'Errico
John D'Errico on 28 Feb 2015
Assuming that x and y are vectors, as is v? Note that your expression is ambiguous, as x could be a scalar.
I'll confidently state there is no analytical solution for v. You could probably write it as the solution of a nonlinear system of equations, so using fsolve.

Categories

Asked:

on 28 Feb 2015

Commented:

on 3 Mar 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!