JSFiddle - React, Tailwind, and code Playground

by webalizer12

HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async
        src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js" integrity="sha512-ElRFoEQdI5Ht6kZvyzXhYG9NqjtkmlkfYk0wr6wHxU9JEHakS7UJZNeml5ALk+8IKlU6jDgMabC3vkumRokgJA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>

<h1> <a href="https://github.com/Pterodactylus/Alglib.js" target="_blank">Alglib.js</a> Curve Fitting</h1>
<h2>An fitting a cubic equation (or arbitrary function) to a dataset using ALGLIB.js</h2>

<p>
    Suppose that we are given a series of points on a graph and we need to  fit them with a cubic polynomial.
    \[ (x_i,y_i) = [[0, 55.932203389830505],
    [1.8237082066869301, 55.932203389830505],
    [3.6474164133738602, 55.932203389830505],
    [5.47112462006079, 55.932203389830505],
    [7.2948328267477205, 81.35593220338983]]\]
</p>
<p>
    We want to choose \(a_0\), \(a_1\), \(a_2\) and \(a_3\) so that the function \(f(x)\) is minimized where
    \[f(x) = a_3x^3+a_2x^2+a_1x+a_0\]
</p>
<p>
    To do this we define a least square equations that gives the sum of the squares of the "error" of the function evaluated at all points.
    \[Sum Squared Error = \sqrt{\sum_{i=1}^5 (y_i - f(x_i))^2}\]
</p>
<p>
    In theory this process can be extended to any arbitrary function.
</p>
<canvas id="myChart" height="400" width="800"></canvas>
<script>
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
    type: "scatter",
    data: {
        datasets: [
          {
            data: {},
            label: 'Actual',
            showLine: false,
            fill: false,
            borderColor: 'red'
          },
          {
            data: {},
            label: 'Cubic...