INNER CODE UNIT · TypeScript

p

margelo/react-native-graph · src/GetYForX.ts:9

  const p = Math.pow(10, precision);
  return Math.round(value * p) / p;
};

// https://stackoverflow.com/questions/27176423/function-to-solve-cubic-equation-analytically
const cuberoot = (x: number): number => {
  'worklet';

  const y = Math.pow(Math.abs(x), 1 / 3);
  return x < 0 ? -y : y;
};

const solveCubic = (a: number, b: number, c: number, d: number): number[] => {
  'worklet';

  if (Math.abs(a) < 1e-8) {
    // Quadratic case, ax^2+bx+c=0
    a = b;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…