Octave coding -- solving a quadratic equation and then using the roots

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 3K views
Ugnius
Messages
54
Reaction score
10
Homework Statement
.
Relevant Equations
.
Hi , I had to solve a quadratic equation , i got two roots as an answer ( ans= x1 / x2) , and now i need to use one of those answers to complete further tasks like finding y from x+y=c so i need to use x1 and x2 from roots , i was wondering if that's possible and how
 
Physics news on Phys.org
Ugnius said:
Homework Statement:: .
Relevant Equations:: .

Hi , I had to solve a quadratic equation , i got two roots as an answer ( ans= x1 / x2) , and now i need to use one of those answers to complete further tasks like finding y from x+y=c so i need to use x1 and x2 from roots , i was wondering if that's possible and how
It seems like you've already done the hard work. The equation ##x + y = c## is equivalent to ##y = -x + c##. Can't you just substitute x1 and x2 here and find y?
 
Mark44 said:
It seems like you've already done the hard work. The equation ##x + y = c## is equivalent to ##y = -x + c##. Can't you just substitute x1 and x2 here and find y?
yea that what i am not able to do because i don't know what function i need to call to get the root1 and root2 as variables
 
i will explain the task - i have to calculate equation system (1.) 6x^2 + 3y^2 = 12 (2.) x+y=2 ; so i can get the x1 and x2 by calculating the first one using substitution , making matrix and calculating roots , but then i need to get y1 and y2 , but i don't know what function i use after the root.
 
Have you written a function that calculates the roots of a quadratic? Your function, if you have one, should return two values. Show us the Octave code you have.
 
Mark44 said:
Have you written a function that calculates the roots of a quadratic? Your function, if you have one, should return two values. Show us the Octave code you have.
I have solved it 3 AM last night , the point was that roots was a 1x2 matrix , but i could use because it was plugged in octave variable so i created another 1x2 matrix , made it equal to roots(A) matrix , and then i could use B(1) and B(2) to get 1st and 2nd root as variables , thanks for the help tho !