How to calculate special vector notation?
I have some problems verifying an already calculated bill in javascript.
I gave some formulas and 2 vectors - but no matter how I calculate, I don't get the right result.
I would be happy if someone could discover my careless mistake and help me, because at the moment I am really helpless.
These vector are given:

These are the formulas for calculating the two angles angles (alpha and beta):

- This is the basic formula for calculation the vectors scale:

Here you can find the result of the calculation (I'm not getting the same result):

This is my javascript code:
let u = [1, -0.2]
let v = [0.5, 0.8]
let mg_u = Math.sqrt(u[0] ** 2 + u[1] ** 2)
let mg_v = Math.sqrt(v[0] ** 2 + v[1] ** 2)
let sc_uv = u[0] * v[0] + u[1] * v[1]
let a = Math.sqrt((mg_v ** 2 - mg_u ** 2 + Math.sqrt((mg_v ** 2 - mg_u ** 2) ** 2 + 4 * (sc_uv ** 2))) / 2)
let b = (-sc_uv) / a
console.log(`alpha: ${a} (valid)`)
console.log(`beta: ${b} (valid)`)
let u_r = [-u[1], u[0]]
let v_r = [-v[1], v[0]]
let scale = Math.sqrt(mg_u ** 2 + a ** 2) /
Math.sqrt(Math.sqrt((v_r[0] - b * u_r[0]) ** 2 + (v_r[1] - b * u_r[1]) ** 2) ** 2 + mg_u ** 2 + mg_v ** 2)
console.log(`scale: ${scale} (probably not valid)`)
let direction = [
v_r[0] - b * u_r[0],
v_r[1] - b * u_r[1],
]
console.log(`direction: ${direction} (not valid)`)javascript math vector calculation
add a comment |
I have some problems verifying an already calculated bill in javascript.
I gave some formulas and 2 vectors - but no matter how I calculate, I don't get the right result.
I would be happy if someone could discover my careless mistake and help me, because at the moment I am really helpless.
These vector are given:

These are the formulas for calculating the two angles angles (alpha and beta):

- This is the basic formula for calculation the vectors scale:

Here you can find the result of the calculation (I'm not getting the same result):

This is my javascript code:
let u = [1, -0.2]
let v = [0.5, 0.8]
let mg_u = Math.sqrt(u[0] ** 2 + u[1] ** 2)
let mg_v = Math.sqrt(v[0] ** 2 + v[1] ** 2)
let sc_uv = u[0] * v[0] + u[1] * v[1]
let a = Math.sqrt((mg_v ** 2 - mg_u ** 2 + Math.sqrt((mg_v ** 2 - mg_u ** 2) ** 2 + 4 * (sc_uv ** 2))) / 2)
let b = (-sc_uv) / a
console.log(`alpha: ${a} (valid)`)
console.log(`beta: ${b} (valid)`)
let u_r = [-u[1], u[0]]
let v_r = [-v[1], v[0]]
let scale = Math.sqrt(mg_u ** 2 + a ** 2) /
Math.sqrt(Math.sqrt((v_r[0] - b * u_r[0]) ** 2 + (v_r[1] - b * u_r[1]) ** 2) ** 2 + mg_u ** 2 + mg_v ** 2)
console.log(`scale: ${scale} (probably not valid)`)
let direction = [
v_r[0] - b * u_r[0],
v_r[1] - b * u_r[1],
]
console.log(`direction: ${direction} (not valid)`)javascript math vector calculation
I had a quick go at calculating the 'so that' using the values supplied in the example and I don't get the same answer, but I could be doing it wrong... is the example you are using wrong?
– Matthew Page
Jan 20 at 11:02
I'm pretty sure the example and it's value are correct. But if we both have the same mistake maybe it is. This would explain a lot.
– jonas00
Jan 20 at 11:04
The given final result is indeed incorrect, or at least inconsistent with the other values. The ratio of the components ofv_r - b * u_ris-0.5822...from the given intermediate values, but-0.4904...from the result.
– meowgoesthedog
Jan 21 at 10:44
add a comment |
I have some problems verifying an already calculated bill in javascript.
I gave some formulas and 2 vectors - but no matter how I calculate, I don't get the right result.
I would be happy if someone could discover my careless mistake and help me, because at the moment I am really helpless.
These vector are given:

These are the formulas for calculating the two angles angles (alpha and beta):

- This is the basic formula for calculation the vectors scale:

Here you can find the result of the calculation (I'm not getting the same result):

This is my javascript code:
let u = [1, -0.2]
let v = [0.5, 0.8]
let mg_u = Math.sqrt(u[0] ** 2 + u[1] ** 2)
let mg_v = Math.sqrt(v[0] ** 2 + v[1] ** 2)
let sc_uv = u[0] * v[0] + u[1] * v[1]
let a = Math.sqrt((mg_v ** 2 - mg_u ** 2 + Math.sqrt((mg_v ** 2 - mg_u ** 2) ** 2 + 4 * (sc_uv ** 2))) / 2)
let b = (-sc_uv) / a
console.log(`alpha: ${a} (valid)`)
console.log(`beta: ${b} (valid)`)
let u_r = [-u[1], u[0]]
let v_r = [-v[1], v[0]]
let scale = Math.sqrt(mg_u ** 2 + a ** 2) /
Math.sqrt(Math.sqrt((v_r[0] - b * u_r[0]) ** 2 + (v_r[1] - b * u_r[1]) ** 2) ** 2 + mg_u ** 2 + mg_v ** 2)
console.log(`scale: ${scale} (probably not valid)`)
let direction = [
v_r[0] - b * u_r[0],
v_r[1] - b * u_r[1],
]
console.log(`direction: ${direction} (not valid)`)javascript math vector calculation
I have some problems verifying an already calculated bill in javascript.
I gave some formulas and 2 vectors - but no matter how I calculate, I don't get the right result.
I would be happy if someone could discover my careless mistake and help me, because at the moment I am really helpless.
These vector are given:

These are the formulas for calculating the two angles angles (alpha and beta):

- This is the basic formula for calculation the vectors scale:

Here you can find the result of the calculation (I'm not getting the same result):

This is my javascript code:
let u = [1, -0.2]
let v = [0.5, 0.8]
let mg_u = Math.sqrt(u[0] ** 2 + u[1] ** 2)
let mg_v = Math.sqrt(v[0] ** 2 + v[1] ** 2)
let sc_uv = u[0] * v[0] + u[1] * v[1]
let a = Math.sqrt((mg_v ** 2 - mg_u ** 2 + Math.sqrt((mg_v ** 2 - mg_u ** 2) ** 2 + 4 * (sc_uv ** 2))) / 2)
let b = (-sc_uv) / a
console.log(`alpha: ${a} (valid)`)
console.log(`beta: ${b} (valid)`)
let u_r = [-u[1], u[0]]
let v_r = [-v[1], v[0]]
let scale = Math.sqrt(mg_u ** 2 + a ** 2) /
Math.sqrt(Math.sqrt((v_r[0] - b * u_r[0]) ** 2 + (v_r[1] - b * u_r[1]) ** 2) ** 2 + mg_u ** 2 + mg_v ** 2)
console.log(`scale: ${scale} (probably not valid)`)
let direction = [
v_r[0] - b * u_r[0],
v_r[1] - b * u_r[1],
]
console.log(`direction: ${direction} (not valid)`)let u = [1, -0.2]
let v = [0.5, 0.8]
let mg_u = Math.sqrt(u[0] ** 2 + u[1] ** 2)
let mg_v = Math.sqrt(v[0] ** 2 + v[1] ** 2)
let sc_uv = u[0] * v[0] + u[1] * v[1]
let a = Math.sqrt((mg_v ** 2 - mg_u ** 2 + Math.sqrt((mg_v ** 2 - mg_u ** 2) ** 2 + 4 * (sc_uv ** 2))) / 2)
let b = (-sc_uv) / a
console.log(`alpha: ${a} (valid)`)
console.log(`beta: ${b} (valid)`)
let u_r = [-u[1], u[0]]
let v_r = [-v[1], v[0]]
let scale = Math.sqrt(mg_u ** 2 + a ** 2) /
Math.sqrt(Math.sqrt((v_r[0] - b * u_r[0]) ** 2 + (v_r[1] - b * u_r[1]) ** 2) ** 2 + mg_u ** 2 + mg_v ** 2)
console.log(`scale: ${scale} (probably not valid)`)
let direction = [
v_r[0] - b * u_r[0],
v_r[1] - b * u_r[1],
]
console.log(`direction: ${direction} (not valid)`)let u = [1, -0.2]
let v = [0.5, 0.8]
let mg_u = Math.sqrt(u[0] ** 2 + u[1] ** 2)
let mg_v = Math.sqrt(v[0] ** 2 + v[1] ** 2)
let sc_uv = u[0] * v[0] + u[1] * v[1]
let a = Math.sqrt((mg_v ** 2 - mg_u ** 2 + Math.sqrt((mg_v ** 2 - mg_u ** 2) ** 2 + 4 * (sc_uv ** 2))) / 2)
let b = (-sc_uv) / a
console.log(`alpha: ${a} (valid)`)
console.log(`beta: ${b} (valid)`)
let u_r = [-u[1], u[0]]
let v_r = [-v[1], v[0]]
let scale = Math.sqrt(mg_u ** 2 + a ** 2) /
Math.sqrt(Math.sqrt((v_r[0] - b * u_r[0]) ** 2 + (v_r[1] - b * u_r[1]) ** 2) ** 2 + mg_u ** 2 + mg_v ** 2)
console.log(`scale: ${scale} (probably not valid)`)
let direction = [
v_r[0] - b * u_r[0],
v_r[1] - b * u_r[1],
]
console.log(`direction: ${direction} (not valid)`)javascript math vector calculation
javascript math vector calculation
asked Jan 20 at 10:29
jonas00jonas00
8921620
8921620
I had a quick go at calculating the 'so that' using the values supplied in the example and I don't get the same answer, but I could be doing it wrong... is the example you are using wrong?
– Matthew Page
Jan 20 at 11:02
I'm pretty sure the example and it's value are correct. But if we both have the same mistake maybe it is. This would explain a lot.
– jonas00
Jan 20 at 11:04
The given final result is indeed incorrect, or at least inconsistent with the other values. The ratio of the components ofv_r - b * u_ris-0.5822...from the given intermediate values, but-0.4904...from the result.
– meowgoesthedog
Jan 21 at 10:44
add a comment |
I had a quick go at calculating the 'so that' using the values supplied in the example and I don't get the same answer, but I could be doing it wrong... is the example you are using wrong?
– Matthew Page
Jan 20 at 11:02
I'm pretty sure the example and it's value are correct. But if we both have the same mistake maybe it is. This would explain a lot.
– jonas00
Jan 20 at 11:04
The given final result is indeed incorrect, or at least inconsistent with the other values. The ratio of the components ofv_r - b * u_ris-0.5822...from the given intermediate values, but-0.4904...from the result.
– meowgoesthedog
Jan 21 at 10:44
I had a quick go at calculating the 'so that' using the values supplied in the example and I don't get the same answer, but I could be doing it wrong... is the example you are using wrong?
– Matthew Page
Jan 20 at 11:02
I had a quick go at calculating the 'so that' using the values supplied in the example and I don't get the same answer, but I could be doing it wrong... is the example you are using wrong?
– Matthew Page
Jan 20 at 11:02
I'm pretty sure the example and it's value are correct. But if we both have the same mistake maybe it is. This would explain a lot.
– jonas00
Jan 20 at 11:04
I'm pretty sure the example and it's value are correct. But if we both have the same mistake maybe it is. This would explain a lot.
– jonas00
Jan 20 at 11:04
The given final result is indeed incorrect, or at least inconsistent with the other values. The ratio of the components of
v_r - b * u_r is -0.5822... from the given intermediate values, but -0.4904... from the result.– meowgoesthedog
Jan 21 at 10:44
The given final result is indeed incorrect, or at least inconsistent with the other values. The ratio of the components of
v_r - b * u_r is -0.5822... from the given intermediate values, but -0.4904... from the result.– meowgoesthedog
Jan 21 at 10:44
add a comment |
0
active
oldest
votes
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%2f54275534%2fhow-to-calculate-special-vector-notation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f54275534%2fhow-to-calculate-special-vector-notation%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
I had a quick go at calculating the 'so that' using the values supplied in the example and I don't get the same answer, but I could be doing it wrong... is the example you are using wrong?
– Matthew Page
Jan 20 at 11:02
I'm pretty sure the example and it's value are correct. But if we both have the same mistake maybe it is. This would explain a lot.
– jonas00
Jan 20 at 11:04
The given final result is indeed incorrect, or at least inconsistent with the other values. The ratio of the components of
v_r - b * u_ris-0.5822...from the given intermediate values, but-0.4904...from the result.– meowgoesthedog
Jan 21 at 10:44