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

Example for Lorenz attractor #3018

Merged
merged 24 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9232a98
broadcasting
dvd101x Feb 7, 2023
c589ad5
Simplified broadcasting
Feb 8, 2023
fbfd332
Updated for broadcasting
Feb 8, 2023
8537fc9
Changed to camel case
Feb 8, 2023
099a7d8
Camel case and auto formating
Feb 8, 2023
3a0aa2d
Added comments
Feb 8, 2023
394c737
Skip if matrices have the same size
dvd101x Feb 9, 2023
772e1db
Fixed issue with undefined variable
dvd101x Feb 9, 2023
2cff0be
Implemented broadcasting in all functions
Feb 9, 2023
6508164
Merge branch 'develop' of https://github.com/dvd101x/mathjs into develop
Feb 9, 2023
3ab4ec9
Added helper functions
dvd101x Feb 12, 2023
899b785
Merge branch 'develop' into develop
dvd101x Feb 12, 2023
0d5fb32
Added function to check for broadcasting rules
dvd101x Feb 12, 2023
3b649ef
Tests for broadcasted arithmetic
Feb 15, 2023
7356dd3
Fixed issue with matrix the size of a vector
Feb 15, 2023
1e2138c
Documented and updated broadcasting
dvd101x Feb 18, 2023
ba8eda2
Included broadcast.test
dvd101x Feb 19, 2023
9a65882
Merge branch 'develop' into develop
josdejong Feb 23, 2023
a04770f
Merge branch 'josdejong:develop' into develop
dvd101x Feb 24, 2023
104310f
Included math to syntax when missing
dvd101x Apr 24, 2023
75e6c70
Merge branch 'develop' of https://github.com/dvd101x/mathjs into develop
dvd101x May 27, 2023
e2bdd4a
Merge branch 'develop' of https://github.com/dvd101x/mathjs into develop
dvd101x Aug 5, 2023
1b67489
Lorenz attractor
dvd101x Aug 15, 2023
a9d2363
Merge branch 'develop' into lorenz
josdejong Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ Evan Miller <[email protected]>
Timur <[email protected]>
Ari Markowitz <[email protected]>
Jay Wang <[email protected]>
David Contreras <[email protected]>
Jaeu Jeong <[email protected]>
cyavictor88 <[email protected]>
David Contreras <[email protected]>
Jakub Riegel <[email protected]>
Angus Comrie <[email protected]>
TMTron <[email protected]>
Expand Down
53 changes: 53 additions & 0 deletions examples/browser/lorenz.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>math.js | Lorenz Attractor</title>
<script src="../../lib/browser/math.js"></script>

<script src="https://cdn.plot.ly/plotly-2.25.2.min.js" charset="utf-8"></script>
</head>

<body>
<div id="LorenzGraph"></div>
</body>
<script defer>

// define the constants for the Lorenz attractor
const sigma = 10
const beta = 2.7
const rho = 28

// solve the Lorenz attractor
const sol = math.solveODE(lorenz, [0, 100], [1, 1, 1])

// make colors that represents time differences in the solution
const diff = math.diff(sol.t)
const color = [diff[0], ...diff]

// render the plot using plotly
Plotly.newPlot('LorenzGraph',
[{
x: sol.y.map(u => u[0]),
y: sol.y.map(u => u[1]),
z: sol.y.map(u => u[2]),
line: { color, colorscale: 'Jet' },
type: "scatter3d",
mode: "lines"
}],
{ width: 800, height: 600 }
)

// define the lorenz attractor
function lorenz(t, u) {
const [x, y, z] = u
return [
sigma * (y - x),
x * (rho - z) - y,
x * y - beta * z
]
}
</script>

</html>