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

Click For Summary

Discussion Overview

The discussion revolves around solving a quadratic equation in Octave, obtaining its roots, and subsequently using these roots to solve a system of equations. Participants explore the process of extracting roots and applying them in further calculations, specifically in the context of a mathematical problem involving equations.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant describes needing to use the roots of a quadratic equation to find values in another equation, specifically in the form of x + y = c.
  • Another participant suggests substituting the roots into the equation y = -x + c to find y.
  • A participant expresses difficulty in accessing the roots as variables from the output of their function.
  • One participant outlines a specific task involving a system of equations and mentions using substitution to find roots, but is unsure how to proceed with obtaining y values.
  • Another participant inquires if the original poster has written a function to calculate the roots of the quadratic equation and requests to see the Octave code used.
  • The original poster later clarifies that they resolved the issue by creating a new matrix to store the roots, allowing them to access the individual roots as variables.

Areas of Agreement / Disagreement

The discussion does not appear to reach a consensus on the best approach initially, as participants express different levels of understanding and methods for accessing the roots. However, the original poster ultimately finds a solution to their problem.

Contextual Notes

Participants discuss the specifics of using Octave for calculations, including the structure of matrices and functions, but do not provide detailed mathematical derivations or assumptions underlying their approaches.

Who May Find This Useful

Individuals working on quadratic equations in Octave, particularly those seeking to understand how to manipulate and use roots in further mathematical tasks.

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 !
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K