Solve A linear equation system b=0 Rstudio
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
i would solve a linear equation system like this:
x_1*3+x_2*4+x_3*5+x_4*6+x_6*2=0
x_1*21+x_2*23+x_3*45+x_4*37*+x_6*0=0
x_1*340+x_2*24+x_3*25+x_4*31+x_6*0=0
x_1*32+x_2*45+x_3*5+x_4*6+x_7*2=0
x_1*9+x_2*11+x_3*13+x_4*49+x_7*0=0
x_1*5+x_2*88+x_3*100+x_4*102+X_7*2=0
[x_1][x_2][x_3] [x_4] [,5]
[1,] 3 4 5 6 2
[2,] 21 23 45 37 0
[3,] 340 24 25 31 0
[4,] 32 45 5 6 2
[5,] 9 11 13 49 0
[6,] 5 88 100 102 2
i use solve this linear homogeneous equation system with MASS::null(t(M)
,
but the problem is that find x_1....x_4, but x_5 find only one solution but i need different three value that is x_5,1,x_5,2 and x_5,3.
value of matrix are random, and they can be changed
r equation equation-solving linear-equation
|
show 1 more comment
i would solve a linear equation system like this:
x_1*3+x_2*4+x_3*5+x_4*6+x_6*2=0
x_1*21+x_2*23+x_3*45+x_4*37*+x_6*0=0
x_1*340+x_2*24+x_3*25+x_4*31+x_6*0=0
x_1*32+x_2*45+x_3*5+x_4*6+x_7*2=0
x_1*9+x_2*11+x_3*13+x_4*49+x_7*0=0
x_1*5+x_2*88+x_3*100+x_4*102+X_7*2=0
[x_1][x_2][x_3] [x_4] [,5]
[1,] 3 4 5 6 2
[2,] 21 23 45 37 0
[3,] 340 24 25 31 0
[4,] 32 45 5 6 2
[5,] 9 11 13 49 0
[6,] 5 88 100 102 2
i use solve this linear homogeneous equation system with MASS::null(t(M)
,
but the problem is that find x_1....x_4, but x_5 find only one solution but i need different three value that is x_5,1,x_5,2 and x_5,3.
value of matrix are random, and they can be changed
r equation equation-solving linear-equation
Look at thesolve
function.
– snaut
Nov 16 '18 at 12:42
@snaut, is not good, because for a Ax=0 return trivial solution
– antonio nuzzo
Nov 16 '18 at 12:49
Ok, sorry I missunderstood what you need. So you want the whole subspace of solutions?
– snaut
Nov 16 '18 at 12:52
yes, but the problem of my system is that there are x_1....x_4 unknows and x_5,1 x_5,2 x_5,3,if the last unknows(x_5) was only one i could have solve the system, but with different x_5 unknows i don't know how solve it.
– antonio nuzzo
Nov 16 '18 at 12:59
Can you explain your notation? I didn't thinkx_5,1
was a legal variable name.
– Carl Witthoft
Nov 16 '18 at 14:19
|
show 1 more comment
i would solve a linear equation system like this:
x_1*3+x_2*4+x_3*5+x_4*6+x_6*2=0
x_1*21+x_2*23+x_3*45+x_4*37*+x_6*0=0
x_1*340+x_2*24+x_3*25+x_4*31+x_6*0=0
x_1*32+x_2*45+x_3*5+x_4*6+x_7*2=0
x_1*9+x_2*11+x_3*13+x_4*49+x_7*0=0
x_1*5+x_2*88+x_3*100+x_4*102+X_7*2=0
[x_1][x_2][x_3] [x_4] [,5]
[1,] 3 4 5 6 2
[2,] 21 23 45 37 0
[3,] 340 24 25 31 0
[4,] 32 45 5 6 2
[5,] 9 11 13 49 0
[6,] 5 88 100 102 2
i use solve this linear homogeneous equation system with MASS::null(t(M)
,
but the problem is that find x_1....x_4, but x_5 find only one solution but i need different three value that is x_5,1,x_5,2 and x_5,3.
value of matrix are random, and they can be changed
r equation equation-solving linear-equation
i would solve a linear equation system like this:
x_1*3+x_2*4+x_3*5+x_4*6+x_6*2=0
x_1*21+x_2*23+x_3*45+x_4*37*+x_6*0=0
x_1*340+x_2*24+x_3*25+x_4*31+x_6*0=0
x_1*32+x_2*45+x_3*5+x_4*6+x_7*2=0
x_1*9+x_2*11+x_3*13+x_4*49+x_7*0=0
x_1*5+x_2*88+x_3*100+x_4*102+X_7*2=0
[x_1][x_2][x_3] [x_4] [,5]
[1,] 3 4 5 6 2
[2,] 21 23 45 37 0
[3,] 340 24 25 31 0
[4,] 32 45 5 6 2
[5,] 9 11 13 49 0
[6,] 5 88 100 102 2
i use solve this linear homogeneous equation system with MASS::null(t(M)
,
but the problem is that find x_1....x_4, but x_5 find only one solution but i need different three value that is x_5,1,x_5,2 and x_5,3.
value of matrix are random, and they can be changed
r equation equation-solving linear-equation
r equation equation-solving linear-equation
edited Nov 16 '18 at 14:29
antonio nuzzo
asked Nov 16 '18 at 12:23
antonio nuzzoantonio nuzzo
177
177
Look at thesolve
function.
– snaut
Nov 16 '18 at 12:42
@snaut, is not good, because for a Ax=0 return trivial solution
– antonio nuzzo
Nov 16 '18 at 12:49
Ok, sorry I missunderstood what you need. So you want the whole subspace of solutions?
– snaut
Nov 16 '18 at 12:52
yes, but the problem of my system is that there are x_1....x_4 unknows and x_5,1 x_5,2 x_5,3,if the last unknows(x_5) was only one i could have solve the system, but with different x_5 unknows i don't know how solve it.
– antonio nuzzo
Nov 16 '18 at 12:59
Can you explain your notation? I didn't thinkx_5,1
was a legal variable name.
– Carl Witthoft
Nov 16 '18 at 14:19
|
show 1 more comment
Look at thesolve
function.
– snaut
Nov 16 '18 at 12:42
@snaut, is not good, because for a Ax=0 return trivial solution
– antonio nuzzo
Nov 16 '18 at 12:49
Ok, sorry I missunderstood what you need. So you want the whole subspace of solutions?
– snaut
Nov 16 '18 at 12:52
yes, but the problem of my system is that there are x_1....x_4 unknows and x_5,1 x_5,2 x_5,3,if the last unknows(x_5) was only one i could have solve the system, but with different x_5 unknows i don't know how solve it.
– antonio nuzzo
Nov 16 '18 at 12:59
Can you explain your notation? I didn't thinkx_5,1
was a legal variable name.
– Carl Witthoft
Nov 16 '18 at 14:19
Look at the
solve
function.– snaut
Nov 16 '18 at 12:42
Look at the
solve
function.– snaut
Nov 16 '18 at 12:42
@snaut, is not good, because for a Ax=0 return trivial solution
– antonio nuzzo
Nov 16 '18 at 12:49
@snaut, is not good, because for a Ax=0 return trivial solution
– antonio nuzzo
Nov 16 '18 at 12:49
Ok, sorry I missunderstood what you need. So you want the whole subspace of solutions?
– snaut
Nov 16 '18 at 12:52
Ok, sorry I missunderstood what you need. So you want the whole subspace of solutions?
– snaut
Nov 16 '18 at 12:52
yes, but the problem of my system is that there are x_1....x_4 unknows and x_5,1 x_5,2 x_5,3,if the last unknows(x_5) was only one i could have solve the system, but with different x_5 unknows i don't know how solve it.
– antonio nuzzo
Nov 16 '18 at 12:59
yes, but the problem of my system is that there are x_1....x_4 unknows and x_5,1 x_5,2 x_5,3,if the last unknows(x_5) was only one i could have solve the system, but with different x_5 unknows i don't know how solve it.
– antonio nuzzo
Nov 16 '18 at 12:59
Can you explain your notation? I didn't think
x_5,1
was a legal variable name.– Carl Witthoft
Nov 16 '18 at 14:19
Can you explain your notation? I didn't think
x_5,1
was a legal variable name.– Carl Witthoft
Nov 16 '18 at 14:19
|
show 1 more comment
2 Answers
2
active
oldest
votes
Ok, had to reactivate my rusted linear algebra knowledge, you can do this by using the Singular Value Decomposition, if all elements of the diagonal part of the SVD are non zero, only the trivial solutions exists:
solution_space <- function(A){
my_svd <- svd(A)
if(all(my_svd$d != 0)){
return(rep(0, ncol(A)))
} else {
return(my_svd$u[,my_svd$d == 0, drop=F])
}
}
A %*% solution_space(A)
You can try the code with these matrices:
A <- matrix(c(1,1,0,1,1,0,0,0,1), 3, 3)
A <- matrix(c(1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1), 4, 4)
A <- matrix(c(1,1,0,1,1,0,0,0,0), 3, 3)
add a comment |
With the update which shows you've got 5 equations with 7 unknowns, it's obvious that there is a multidimensional surface of solutions.
I fear I don't have code to calculate that surface, but let me toot my own horn and offer the ktsolve
package. For any given set of inputs from your { $x_1, x_2, ...x_7$ } [ah rats no latex markdown] , enter a collection of known values and ktsolve
will run a back-solver (usually BB
) to find the unknowns.
So if you can feed your problem a selected set of any two of {X_5, X_6, X_7}, you can find all five of the other values.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337864%2fsolve-a-linear-equation-system-b-0-rstudio%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ok, had to reactivate my rusted linear algebra knowledge, you can do this by using the Singular Value Decomposition, if all elements of the diagonal part of the SVD are non zero, only the trivial solutions exists:
solution_space <- function(A){
my_svd <- svd(A)
if(all(my_svd$d != 0)){
return(rep(0, ncol(A)))
} else {
return(my_svd$u[,my_svd$d == 0, drop=F])
}
}
A %*% solution_space(A)
You can try the code with these matrices:
A <- matrix(c(1,1,0,1,1,0,0,0,1), 3, 3)
A <- matrix(c(1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1), 4, 4)
A <- matrix(c(1,1,0,1,1,0,0,0,0), 3, 3)
add a comment |
Ok, had to reactivate my rusted linear algebra knowledge, you can do this by using the Singular Value Decomposition, if all elements of the diagonal part of the SVD are non zero, only the trivial solutions exists:
solution_space <- function(A){
my_svd <- svd(A)
if(all(my_svd$d != 0)){
return(rep(0, ncol(A)))
} else {
return(my_svd$u[,my_svd$d == 0, drop=F])
}
}
A %*% solution_space(A)
You can try the code with these matrices:
A <- matrix(c(1,1,0,1,1,0,0,0,1), 3, 3)
A <- matrix(c(1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1), 4, 4)
A <- matrix(c(1,1,0,1,1,0,0,0,0), 3, 3)
add a comment |
Ok, had to reactivate my rusted linear algebra knowledge, you can do this by using the Singular Value Decomposition, if all elements of the diagonal part of the SVD are non zero, only the trivial solutions exists:
solution_space <- function(A){
my_svd <- svd(A)
if(all(my_svd$d != 0)){
return(rep(0, ncol(A)))
} else {
return(my_svd$u[,my_svd$d == 0, drop=F])
}
}
A %*% solution_space(A)
You can try the code with these matrices:
A <- matrix(c(1,1,0,1,1,0,0,0,1), 3, 3)
A <- matrix(c(1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1), 4, 4)
A <- matrix(c(1,1,0,1,1,0,0,0,0), 3, 3)
Ok, had to reactivate my rusted linear algebra knowledge, you can do this by using the Singular Value Decomposition, if all elements of the diagonal part of the SVD are non zero, only the trivial solutions exists:
solution_space <- function(A){
my_svd <- svd(A)
if(all(my_svd$d != 0)){
return(rep(0, ncol(A)))
} else {
return(my_svd$u[,my_svd$d == 0, drop=F])
}
}
A %*% solution_space(A)
You can try the code with these matrices:
A <- matrix(c(1,1,0,1,1,0,0,0,1), 3, 3)
A <- matrix(c(1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1), 4, 4)
A <- matrix(c(1,1,0,1,1,0,0,0,0), 3, 3)
answered Nov 16 '18 at 13:50
snautsnaut
1,0761020
1,0761020
add a comment |
add a comment |
With the update which shows you've got 5 equations with 7 unknowns, it's obvious that there is a multidimensional surface of solutions.
I fear I don't have code to calculate that surface, but let me toot my own horn and offer the ktsolve
package. For any given set of inputs from your { $x_1, x_2, ...x_7$ } [ah rats no latex markdown] , enter a collection of known values and ktsolve
will run a back-solver (usually BB
) to find the unknowns.
So if you can feed your problem a selected set of any two of {X_5, X_6, X_7}, you can find all five of the other values.
add a comment |
With the update which shows you've got 5 equations with 7 unknowns, it's obvious that there is a multidimensional surface of solutions.
I fear I don't have code to calculate that surface, but let me toot my own horn and offer the ktsolve
package. For any given set of inputs from your { $x_1, x_2, ...x_7$ } [ah rats no latex markdown] , enter a collection of known values and ktsolve
will run a back-solver (usually BB
) to find the unknowns.
So if you can feed your problem a selected set of any two of {X_5, X_6, X_7}, you can find all five of the other values.
add a comment |
With the update which shows you've got 5 equations with 7 unknowns, it's obvious that there is a multidimensional surface of solutions.
I fear I don't have code to calculate that surface, but let me toot my own horn and offer the ktsolve
package. For any given set of inputs from your { $x_1, x_2, ...x_7$ } [ah rats no latex markdown] , enter a collection of known values and ktsolve
will run a back-solver (usually BB
) to find the unknowns.
So if you can feed your problem a selected set of any two of {X_5, X_6, X_7}, you can find all five of the other values.
With the update which shows you've got 5 equations with 7 unknowns, it's obvious that there is a multidimensional surface of solutions.
I fear I don't have code to calculate that surface, but let me toot my own horn and offer the ktsolve
package. For any given set of inputs from your { $x_1, x_2, ...x_7$ } [ah rats no latex markdown] , enter a collection of known values and ktsolve
will run a back-solver (usually BB
) to find the unknowns.
So if you can feed your problem a selected set of any two of {X_5, X_6, X_7}, you can find all five of the other values.
answered Nov 16 '18 at 14:45
Carl WitthoftCarl Witthoft
16.1k63458
16.1k63458
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337864%2fsolve-a-linear-equation-system-b-0-rstudio%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Look at the
solve
function.– snaut
Nov 16 '18 at 12:42
@snaut, is not good, because for a Ax=0 return trivial solution
– antonio nuzzo
Nov 16 '18 at 12:49
Ok, sorry I missunderstood what you need. So you want the whole subspace of solutions?
– snaut
Nov 16 '18 at 12:52
yes, but the problem of my system is that there are x_1....x_4 unknows and x_5,1 x_5,2 x_5,3,if the last unknows(x_5) was only one i could have solve the system, but with different x_5 unknows i don't know how solve it.
– antonio nuzzo
Nov 16 '18 at 12:59
Can you explain your notation? I didn't think
x_5,1
was a legal variable name.– Carl Witthoft
Nov 16 '18 at 14:19