Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System of equations #15

Open
AmityWilder opened this issue Nov 29, 2023 · 2 comments
Open

System of equations #15

AmityWilder opened this issue Nov 29, 2023 · 2 comments
Assignees
Labels
complexity is foggy Issue contains factors I am not experienced with; I cannot accurately predict the true complexity complexity is impl. dependent There is more than one possible solution to this issue, and some may be simpler than others complexity is planning > execution Planning will be more difficult than implementing the solution complexity: 3 - high Could take multiple days and likely requires planning ahead enhancement New feature or request priority: 2 - medium Should probably do this sooner rather than later
Milestone

Comments

@AmityWilder
Copy link
Owner

The calculator (or macro) section should have an option to solve for $n$ variables in a systems of $n$ equations.

@AmityWilder AmityWilder added enhancement New feature or request complexity: 3 - high Could take multiple days and likely requires planning ahead priority: 2 - medium Should probably do this sooner rather than later complexity is foggy Issue contains factors I am not experienced with; I cannot accurately predict the true complexity complexity is planning > execution Planning will be more difficult than implementing the solution complexity is impl. dependent There is more than one possible solution to this issue, and some may be simpler than others labels Nov 29, 2023
@AmityWilder AmityWilder added this to the 1.0 Release milestone Nov 29, 2023
@AmityWilder AmityWilder self-assigned this Nov 29, 2023
@AmityWilder
Copy link
Owner Author

Idea 1

It seems a little complicated, but this might be possible?
image
image

@AmityWilder
Copy link
Owner Author

AmityWilder commented Nov 29, 2023

Idea 2

This might require some more complex input or parsing, but it might be simpler overall.
image

Simpler, because I think it might be easier to write intermediate functions for.

Something like

interface Equation {
  xCoef:    number;
  yCoef:    number;
  solution: number;
}

/** @returns Reciprocal of system1 */
const reciprocalEq = (system1: Equation, system2: Equation): Equation => {
  const quotient: number = -(system1.xCoef / system2.xCoef);
  return {
    xCoef:    system1.xCoef    * quotient,
    yCoef:    system1.yCoef    * quotient,
    solution: system1.solution * quotient
  };
};

const sumOfEqs = (system1: Equation, system2: Equation): Equation => {
  return {
    xCoef:    system1.xCoef    + system2.xCoef,
    yCoef:    system1.yCoef    + system2.yCoef,
    solution: system1.solution + system2.solution
  };
};

/** @returns Value of y. */
const systemOfEquations = (system1: Equation, system2: Equation): number => {
  const reciprocal: Equation = reciprocalEq(system1, system2);
  const sum: Equation = sumOfEqs(reciprocal , system2);
  const y: number = sum.solution / sum.yCoef;
  return y;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity is foggy Issue contains factors I am not experienced with; I cannot accurately predict the true complexity complexity is impl. dependent There is more than one possible solution to this issue, and some may be simpler than others complexity is planning > execution Planning will be more difficult than implementing the solution complexity: 3 - high Could take multiple days and likely requires planning ahead enhancement New feature or request priority: 2 - medium Should probably do this sooner rather than later
Projects
Status: Todo
Development

No branches or pull requests

1 participant