finding vector from an equation

2 Ansichten (letzte 30 Tage)
Talya Klein
Talya Klein am 6 Okt. 2020
Bearbeitet: John D'Errico am 6 Okt. 2020
Hi everyone,
I have an equation equal to zero, in this equation I have 'g' how is a vector I am tring to find.
my equation:
norm(g(2:end)*s - g(1:end-1)) + norm(g +3) == 0
s- is a known array (100x1)
g- is a 100x1 vector that I want to find
I tired usying 'syms', 'sym' and 'solve' but couldn't find what 'g' is.
Thanks in advance

Antworten (2)

Walter Roberson
Walter Roberson am 6 Okt. 2020
If g were 100 x 1 then your g(2:end)*s would have a size error.
If you mean * as matrix multiplication (inner product) then you have the problem that both g(2:end) and s are column vectors, and so the size would not be appropriate for matrix multiplication.
If you mean * as element-by-element multiplication, then you have the problem that g(2:end) would be length 99 but s would be length 100.
If you do
syms g [1 101]
eqn = norm(g(2:end).*s - g(1:end-1)) + norm(g +3) == 0
then if you are willing to add the assumption that g is real-valued then norm(x) is sqrt(sum(x.^2)) so you would have
eqn = sqrt(sum((g(2:end).*s).^2)) + sqrt(sum((g+3).^2)) == 0
That would be a single equation in 100 variables. Solve for any one of the variables such as g(1) and the other ones can be any finite real values.
  1 Kommentar
Talya Klein
Talya Klein am 6 Okt. 2020
Thank you for the quick response.
The equation I wrote is not the one I am using, the numbers are slightly different. 's' is supposed to be the size of 99.
By * I meant element-by-element multiplication.
I don't fully understand why you add the sum to the equation, and how does it help me find 'g'

Melden Sie sich an, um zu kommentieren.


John D'Errico
John D'Errico am 6 Okt. 2020
Bearbeitet: John D'Errico am 6 Okt. 2020
There is no solution. Except for possibly a trivial solution. And with some effort, I can prove that does not exist.
norm(g(2:end)*s - g(1:end-1)) + norm(g +3) == 0
What are some properties we ABSOLUTELY KNOW about a vector norm? There are two that come to mind.
A norm is always a real number, and it is always at least non-negative. It could be zero, but then only if every element of the vector is also zero. Your equation has the addition of two vector norms equal to zero.
Therefore, each of the norms in that sum must be identically zero. So we can write:
norm(g+3) == 0
For the norm to be zero, that tells us that every element of g must be -3, since every element of g+3 must be zero. Therefore. g is a vector of length 100, that is identically -3 in every element.
So if a solution can ever exist, then we would need to have the other part of this also identially zero. We already know what g is. We know what s is. So only if the first norm can be already zero does a solution exist.
norm(g(2:end)*s - g(1:end-1) == 0
The fact is, I have no idea what you even intend by this expression. g is a vector of length 100. s is a vector of length 100. Therefore g(2:end)*s is meaningless, because g(2:end) has length 99, and s has length 100.
So we are done. Your "equation" is meaningless as you have writtten it. Perhaps you will tell us that you made a mistake in how you wrote the equation, that you intended something completely different. But as is, it has no meaning in mathematics.
  1 Kommentar
John D'Errico
John D'Errico am 6 Okt. 2020
Bearbeitet: John D'Errico am 6 Okt. 2020
So we learn that s is not indeed of length 100, but length 99. Even so, the vector g MUST be identically -3.
This results because the term norm(g+3) can never be a number that is less than zero. And since we have the sum of two norms that MUST be zero, then they BOTH must be identically zero. Therefore we can unequivocally state that
g == repmat(-3,1,100)
Norms are ALWAYS positive, unless they are zero. Period. And when a norm is zero, then every element of the vector must be zero. (See below.)
Given that, we have the second term. It is
norm(g(2:end).*s - g(1:end-1))
Note my use of .* there, instead of *, as you used. This indicates element-wise multiplication. So this second norm reduces to:
norm(-3*s - repmat(-3,1,99))
And that can ONLY ever be exctly zeroif EVERY element is identically zero. Again, this is a basic fact about norms. That implies the requirement that
-3*s(i) - (-3) == 0
We can trivially rewrite this as:
s(i) = 1
My point? There is ONLY ONE possible solution to this problem. It arises when ALL of the elements of the vector s are IDENTICALLY equal to 1. Pick any other elements for the vector s, and no solution can EVER exist. PERIOD. When s has this property, then the solution is now simple. It is the vector g as I have indicated.
So here is MATLAB code to solve your problem. It even works for any length vector s.
if all(s == 1)
g = repmat(-3,1,length(s)+1);
else
error('No solution can ever be possible')
end
Seriously, that is all there is to the problem. I don't know how or why you think any other solution can exist. But this is pretty basic mathematics. Norms are simple things. Do some reading:
For example, in there, you will find statements like this:
"If p(v) = 0 then v = 0 is the zero vector (being positive definite or being point-separating)."
We really don't even need to worry about which norm you are using. Euclidean norm? Fine. Infinity norm? 1-norm? Still no problem. They all apply. These are fundamental properties of a norm in a vector space. If the norm of a vector is zero, then the elements of the vector must all be zero.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Formula Manipulation and Simplification finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by