|
|
Line 1: |
Line 1: |
| == Operating system == | | % Define the function dy/dx = yx - x^3 |
| | f = @(x, y) y*x - x^3; |
|
| |
|
| === Commercial === | | % Initial conditions |
| | x0 = 0; |
| | y0 = 1; |
| | h = 0.6; |
| | xf = 1.8; |
|
| |
|
| <gallery>
| | % Number of steps |
| File:Windows darkblue 2012.svg|link=Octave for Microsoft Windows|[[Octave for Microsoft Windows|Microsoft Windows]]
| | n = round((xf - x0) / h); |
| File:MacOS wordmark (2017).svg|link=Octave for macOS|[[Octave for macOS|macOS]]
| |
| </gallery>
| |
|
| |
|
| === [[Octave for GNU/Linux|GNU/Linux]] ===
| | % Initialize arrays for solutions |
| | x_values = x0:h:xf; |
|
| |
|
| * '''Distributions''' | | % Euler's Explicit Method |
| | y_euler = zeros(1, n+1); |
| | y_euler(1) = y0; |
| | for i = 1:n |
| | y_euler(i+1) = y_euler(i) + h * f(x_values(i), y_euler(i)); |
| | end |
|
| |
|
| <gallery>
| |
| File:Debian-OpenLogo.svg|link=Octave for Debian systems|[[Octave for Debian systems|Debian]]
| |
| File:Logo-ubuntu cof-orange-hex.svg|link=Octave for Debian systems|[[Octave for Debian systems|Ubuntu]]
| |
| File:Archlinux-vert-dark.svg|link=Octave for Arch Linux|[[Octave for Arch Linux|Arch Linux]]
| |
| File:Slackware_logo.svg|link=Octave for Slackware|[[Octave for Slackware|Slackware]]
| |
| File:Gentoo_Linux_logo_matte.svg|link=Octave for GNU/Linux#Gentoo|[[Octave for GNU/Linux#Gentoo|Gentoo]]
| |
| File:Fedora logo.svg|link=Octave for Red Hat Linux systems|[[Octave for Red Hat Linux systems|Fedora]]
| |
| File:OpenSUSE Logo.svg|link=Octave for openSUSE|[[Octave for openSUSE|openSUSE]]
| |
| File:CentOS_color_logo.svg|link=Octave for Red Hat Linux systems|[[Octave for Red Hat Linux systems|CentOS]]
| |
| File:Tux.png|link=Octave for Red Hat Linux systems|[[Octave for Red Hat Linux systems|RHEL]]
| |
| </gallery>
| |
|
| |
|
| | % Display results |
| | disp('x values:'), disp(x_values); |
| | disp('Euler method results:'), disp(y_euler); |
|
| |
|
| * '''Distribution independent'''
| |
|
| |
|
| <gallery>
| | % Plot the solutions |
| File:Docker (container engine) logo.svg|link=Octave for GNU/Linux#Docker|[[Octave for GNU/Linux#Docker_.2F_Podman_.2F_Singularity|Docker / Podman / Singularity]]
| | figure; |
| File:Flatpak logo.png|link=Octave for GNU/Linux#Flatpak|[[Octave for GNU/Linux#Flatpak|Flatpak]]
| | plot(x_values, y_euler, '-o', 'DisplayName', 'Euler Method'); |
| File:Guix logo.svg|link=Octave for GNU/Linux#Guix|[[Octave for GNU/Linux#Guix|Guix]]
| | hold on; |
| File:Brew_logo.svg|link=Octave for GNU/Linux#Homebrew_on_Linux|[[Octave for GNU/Linux#Homebrew_on_Linux|Homebrew]]
| | xlabel('x'); |
| File:Tux.png|link=MXE|[[MXE]]
| | ylabel('y'); |
| File:snapcraft.png|link=Octave for GNU/Linux#Snap|[[Octave for GNU/Linux#Snap|Snap]]
| | title('Solutions to dy/dx = yx - x^3'); |
| </gallery>
| | legend; |
| | | grid on; |
| === [[Octave for other Unix systems|Other Unix systems]] === | |
| | |
| <gallery>
| |
| File:Android_logo_2019.svg|100px|link=Octave for Android|[[Octave for Android|Android]]
| |
| File:Tux.png|link=Octave for other Unix systems|[[Octave for other Unix systems|FreeBSD]]
| |
| File:OpenBSD textual logo.svg|link=Octave for other Unix systems|[[Octave for other Unix systems|OpenBSD]]
| |
| </gallery>
| |
| | |
| == Other ==
| |
| | |
| <gallery>
| |
| File:Jupyter logo.svg|link=https://github.com/Calysto/octave_kernel |[https://github.com/Calysto/octave_kernel Jupyter]
| |
| </gallery>
| |