Wikiversity
betawikiversity
https://beta.wikiversity.org/wiki/Main_Page
MediaWiki 1.47.0-wmf.14
first-letter
Media
Special
Talk
User
User talk
Wikiversity
Wikiversity talk
File
File talk
MediaWiki
MediaWiki talk
Template
Template talk
Help
Help talk
Category
Category talk
TimedText
TimedText talk
Module
Module talk
Translations
Translations talk
Event
Event talk
User:OwlyKnight
2
55636
385934
384944
2026-08-05T09:17:11Z
OwlyKnight
53456
385934
wikitext
text/x-wiki
A Wikimedia user and contributors. Currently trying to revive and to develop Wikiversity bahasa Indonesia ([[:Category:ID|See the current Indonesian pages]]).
{{Collapse top|Sandbox pages}}
* [[/Halaman Utama/]] (moved to [[Halaman Utama]]--2026/06/05), templates:
** [[/Halaman Utama/atas/]] (moved to [[Template:Halaman Utama/atas]]--2026/06/05)
** [[/Halaman Utama/kotak/]] (moved to [[Template:Halaman Utama/kotak]]--2026/06/05)
** [[/Halaman Utama/Awal/]] (moved to [[Template:Halaman Utama/Awal]]--2026/06/05)
** [[/Halaman Utama/Buat materi baru/]] (moved to [[Template:Halaman Utama/Buat materi baru]]--2026/06/05)
** [[/Halaman Utama/Daftar sekolah/]] (moved to [[Template:Halaman Utama/Menjelajah]]--2026/06/05)
** [[/Halaman Utama/Proyek saudari/]] (moved to [[Template:Halaman Utama/Proyek saudari]]--2026/06/05)
* [[/Sekolah/atas/]]
* Policies, standards, and guidelines:
** [[/Wikiversity:Selamat datang/]] -- Welcome page (check: [[:en:Wikiversity:Welcome]]
** [[/Wikiversity:Apa itu Wikiversity?/]] -- Explanation on what is Wikiversity
** [[/Wikiversity:Wikiversity bukanlah/]] -- Explanation on Wikiversity is not something
** [[/Wikiversity:Ruang nama/]] -- Explanation on namespaces
** [[/Wikiversity:Kebijakan/]] -- List of policies
** [[/Wikiversity:Panduan/]] -- List of guidelines
*** [[/Wikiversity:Panduan pembuatan konten/]] -- Guideline to create contents
*** [[/Wikiversity:Panduan gaya/]] -- Style guide (See also [[:id:voy:Wikiwisata:Pedoman_gaya]])
**** [[/Template:Kerangka kelas/]] -- Framework template to create a new class / course (similar to framework template used in Wikivoyage; see: [[:id:voy:Wikiwisata:Templat kerangka artikel]])
**** [[/Template:Kerangka materi/]] -- Framework template to create a new material within a class / course
*** [[/Wikiversity:Panduan pembuatan sekolah/]] -- Guideline to create a new school
*** [[/Wikiversity:Panduan penamaan/]] -- Guideline on naming the contents
{{Collapse bottom}}
== See also ==
* [[meta:User:OwlyKnight|My Meta-Wiki page]]
ot2tm6o3wj4l5e207iatii7pc66f5pe
385935
385934
2026-08-05T09:21:04Z
OwlyKnight
53456
385935
wikitext
text/x-wiki
A Wikimedia user and contributors. Currently trying to revive and to develop Wikiversity bahasa Indonesia ([[:Category:ID|See the current Indonesian pages]]).
{{Collapse top|Sandbox pages}}
* [[/Halaman Utama/]] (moved to [[Halaman Utama]]--2026/06/05), templates:
** [[/Halaman Utama/atas/]] (moved to [[Template:Halaman Utama/atas]]--2026/06/05)
** [[/Halaman Utama/kotak/]] (moved to [[Template:Halaman Utama/kotak]]--2026/06/05)
** [[/Halaman Utama/Awal/]] (moved to [[Template:Halaman Utama/Awal]]--2026/06/05)
** [[/Halaman Utama/Buat materi baru/]] (moved to [[Template:Halaman Utama/Buat materi baru]]--2026/06/05)
** [[/Halaman Utama/Daftar sekolah/]] (moved to [[Template:Halaman Utama/Menjelajah]]--2026/06/05)
** [[/Halaman Utama/Proyek saudari/]] (moved to [[Template:Halaman Utama/Proyek saudari]]--2026/06/05)
* [[/Sekolah/atas/]]
* Policies, standards, and guidelines:
** [[/Wikiversity:Selamat datang/]] -- Welcome page (check: [[:en:Wikiversity:Welcome]])
** [[/Wikiversity:Apa itu Wikiversity?/]] -- Explanation on what is Wikiversity (check: [[:en:Wikiversity:What is Wikiversity?]])
** [[/Wikiversity:Wikiversity bukanlah/]] -- Explanation on Wikiversity is not something (check: [[:en:Wikiversity:What Wikiversity is not]])
** [[/Wikiversity:Ruang nama/]] -- Explanation on namespaces (check: [[:en:Wikiversity:Namespace]])
** [[/Wikiversity:Kebijakan/]] -- List of policies
** [[/Wikiversity:Panduan/]] -- List of guidelines
*** [[/Wikiversity:Panduan pembuatan konten/]] -- Guideline to create contents
*** [[/Wikiversity:Panduan gaya/]] -- Style guide (See also [[:id:voy:Wikiwisata:Pedoman_gaya]])
**** [[/Template:Kerangka kelas/]] -- Framework template to create a new class / course (similar to framework template used in Wikivoyage; see: [[:id:voy:Wikiwisata:Templat kerangka artikel]])
**** [[/Template:Kerangka materi/]] -- Framework template to create a new material within a class / course
*** [[/Wikiversity:Panduan pembuatan sekolah/]] -- Guideline to create a new school
*** [[/Wikiversity:Panduan penamaan/]] -- Guideline on naming the contents (check: [[:en:Wikiversity:Naming conventions]])
{{Collapse bottom}}
== See also ==
* [[meta:User:OwlyKnight|My Meta-Wiki page]]
12mhq5azhicwvdzh6np232h3ywcamfr
Talk:Halaman Utama
1
55680
385917
385510
2026-08-05T03:58:15Z
OwlyKnight
53456
/* Dukungan dan Komentar */ Reply
385917
wikitext
text/x-wiki
== Dukungan dan Komentar ==
Hi hi!
Rencananya Halaman Utama ini akan menjadi halaman utama pengembangan proyek Wikiversitas bahasa Indonesia. Apabila berkenan, boleh memberikan dukungan atau komentar di bawah. Terima kasih!
<small>Saya rencananya ingin membuat pertemuan daring untuk membahas proyek ini.</small>
[[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 11:09, 6 June 2026 (UTC)
:Halo OwlyKnight!
:Terima kasih sudah merintis Halaman Utama ini. Saya sangat mendukung penuh pengembangan Wikiversitas bahasa Indonesia.
:Saat ini saya sedang menyusun beberapa modul dan materi pembelajaran terbuka untuk Matematika Keuangan. Semoga kontribusi ini bisa membantu menambah beberapa bacaan. Kapan saja ada rencana diskusi atau koordinasi lebih lanjut maupun informasi aturan-aturan khusus lainnya dalam penulisan, saya siap menyimak dan mendukung.
:Salam hangat!
:[[User:Satya Rambana|Satya Rambana]] ([[User talk:Satya Rambana|talk]]) 01:27, 28 July 2026 (UTC)
:Halo OwlyKnight!
:Saya sedang mencoba untuk menuliskan persamaan matematika, menggunakan referensi yang ada seperti di Wikipedia bahasa Indonesia (https://id.wikipedia.org/wiki/Bantuan:Menampilkan_rumus) menggunakan penulisan Sintaks HTML. Namun, saya mendapati bahwa kemudian teks {{math}} menghasilkan tampilan teks dengan warna merah dan menunjukkan Template:Math (pages does not exist). Apakah terdapat cara tertentu untuk menuliskan persamaan matematika di Wikiversitas bahasa Indonesia? Terima kasih. [[User:Satya Rambana|Satya Rambana]] ([[User talk:Satya Rambana|talk]]) 03:00, 28 July 2026 (UTC)
::Halo, @[[User:Satya Rambana|Satya Rambana]]! Terima kasih banyak untuk antusiasmenya. Mohon maaf karena saya terlambat membalas pesan Anda di sini. Untuk Template:Math sepertinya belum ada di situs ini. Akan saya coba migrasi ke sini (bersama dengan templat-templat yang mungkin diperlukan) dan mungkin terjemahkan beberapa menjadi bahasa Indonesia, misalnya Template:Math menjadi Template:Matematika / Templat:Mat. Terima kasih! [[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 03:58, 5 August 2026 (UTC)
0bfoty82wiwsuxijbiy4jcyovhdsx74
385932
385917
2026-08-05T09:01:07Z
OwlyKnight
53456
/* Dukungan dan Komentar */ Reply
385932
wikitext
text/x-wiki
== Dukungan dan Komentar ==
Hi hi!
Rencananya Halaman Utama ini akan menjadi halaman utama pengembangan proyek Wikiversitas bahasa Indonesia. Apabila berkenan, boleh memberikan dukungan atau komentar di bawah. Terima kasih!
<small>Saya rencananya ingin membuat pertemuan daring untuk membahas proyek ini.</small>
[[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 11:09, 6 June 2026 (UTC)
:Halo OwlyKnight!
:Terima kasih sudah merintis Halaman Utama ini. Saya sangat mendukung penuh pengembangan Wikiversitas bahasa Indonesia.
:Saat ini saya sedang menyusun beberapa modul dan materi pembelajaran terbuka untuk Matematika Keuangan. Semoga kontribusi ini bisa membantu menambah beberapa bacaan. Kapan saja ada rencana diskusi atau koordinasi lebih lanjut maupun informasi aturan-aturan khusus lainnya dalam penulisan, saya siap menyimak dan mendukung.
:Salam hangat!
:[[User:Satya Rambana|Satya Rambana]] ([[User talk:Satya Rambana|talk]]) 01:27, 28 July 2026 (UTC)
:Halo OwlyKnight!
:Saya sedang mencoba untuk menuliskan persamaan matematika, menggunakan referensi yang ada seperti di Wikipedia bahasa Indonesia (https://id.wikipedia.org/wiki/Bantuan:Menampilkan_rumus) menggunakan penulisan Sintaks HTML. Namun, saya mendapati bahwa kemudian teks {{math}} menghasilkan tampilan teks dengan warna merah dan menunjukkan Template:Math (pages does not exist). Apakah terdapat cara tertentu untuk menuliskan persamaan matematika di Wikiversitas bahasa Indonesia? Terima kasih. [[User:Satya Rambana|Satya Rambana]] ([[User talk:Satya Rambana|talk]]) 03:00, 28 July 2026 (UTC)
::Halo, @[[User:Satya Rambana|Satya Rambana]]! Terima kasih banyak untuk antusiasmenya. Mohon maaf karena saya terlambat membalas pesan Anda di sini. Untuk Template:Math sepertinya belum ada di situs ini. Akan saya coba migrasi ke sini (bersama dengan templat-templat yang mungkin diperlukan) dan mungkin terjemahkan beberapa menjadi bahasa Indonesia, misalnya Template:Math menjadi Template:Matematika / Templat:Mat. Terima kasih! [[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 03:58, 5 August 2026 (UTC)
::Halo, @[[User:Satya Rambana|Satya Rambana]]! Saya sudah membuat beberapa templat matematika yang bisa dicek di sini: [[:Category:Templat format matematika]]. Secara umum, saya mengubah beberapa nama templat menjadi seperti berikut:
::* <nowiki>{{math}} → {{</nowiki>[[Template:matematika]]}}
::* <nowiki>{{mvar}} → {{</nowiki>[[Template:mvar]]}} (tidak berubah)
::* <nowiki>{{sfrac}} → {{</nowiki>[[Template:pecahan]]}}
::* <nowiki>{{sub}} → {{</nowiki>[[Template:subskrip]]}}
::* <nowiki>{{sup}} → {{</nowiki>[[Template:superskrip]]}}
::* <nowiki>{{su}} → {{</nowiki>[[Template:subsup]]}}
::* <nowiki>{{overline}} → {{</nowiki>[[Template:garis atas]]}}
::* <nowiki>{{overset}} → {{</nowiki>[[Template:set atas]]}}
::* <nowiki>{{underset}} → {{</nowiki>[[Template:set bawah]]}}
::Terima kasih banyak! :D [[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 09:01, 5 August 2026 (UTC)
gmf5sqi1lz02qe2anrs42e7qgzwgt96
385933
385932
2026-08-05T09:04:49Z
OwlyKnight
53456
385933
wikitext
text/x-wiki
== Dukungan dan Komentar ==
Hi hi!
Rencananya Halaman Utama ini akan menjadi halaman utama pengembangan proyek Wikiversitas bahasa Indonesia. Apabila berkenan, boleh memberikan dukungan atau komentar di bawah. Terima kasih!
<small>Saya rencananya ingin membuat pertemuan daring untuk membahas proyek ini.</small>
[[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 11:09, 6 June 2026 (UTC)
:Halo OwlyKnight!
:Terima kasih sudah merintis Halaman Utama ini. Saya sangat mendukung penuh pengembangan Wikiversitas bahasa Indonesia.
:Saat ini saya sedang menyusun beberapa modul dan materi pembelajaran terbuka untuk Matematika Keuangan. Semoga kontribusi ini bisa membantu menambah beberapa bacaan. Kapan saja ada rencana diskusi atau koordinasi lebih lanjut maupun informasi aturan-aturan khusus lainnya dalam penulisan, saya siap menyimak dan mendukung.
:Salam hangat!
:[[User:Satya Rambana|Satya Rambana]] ([[User talk:Satya Rambana|talk]]) 01:27, 28 July 2026 (UTC)
:Halo OwlyKnight!
:Saya sedang mencoba untuk menuliskan persamaan matematika, menggunakan referensi yang ada seperti di Wikipedia bahasa Indonesia (https://id.wikipedia.org/wiki/Bantuan:Menampilkan_rumus) menggunakan penulisan Sintaks HTML. Namun, saya mendapati bahwa kemudian teks {{math}} menghasilkan tampilan teks dengan warna merah dan menunjukkan Template:Math (pages does not exist). Apakah terdapat cara tertentu untuk menuliskan persamaan matematika di Wikiversitas bahasa Indonesia? Terima kasih. [[User:Satya Rambana|Satya Rambana]] ([[User talk:Satya Rambana|talk]]) 03:00, 28 July 2026 (UTC)
::Halo, @[[User:Satya Rambana|Satya Rambana]]! Terima kasih banyak untuk antusiasmenya. Mohon maaf karena saya terlambat membalas pesan Anda di sini. Untuk Template:Math sepertinya belum ada di situs ini. Akan saya coba migrasi ke sini (bersama dengan templat-templat yang mungkin diperlukan) dan mungkin terjemahkan beberapa menjadi bahasa Indonesia, misalnya Template:Math menjadi Template:Matematika / Templat:Mat. Terima kasih! [[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 03:58, 5 August 2026 (UTC)
::Halo, @[[User:Satya Rambana|Satya Rambana]]! Saya sudah membuat beberapa templat matematika yang bisa dicek di sini: [[:Category:Templat format matematika]]. Secara umum, saya mengubah beberapa nama templat menjadi seperti berikut:
::* <nowiki>{{math}} → {{</nowiki>[[Template:matematika|matematika]]}}
::* <nowiki>{{mvar}} → {{</nowiki>[[Template:mvar|mvar]]}} (tidak berubah)
::* <nowiki>{{sfrac}} → {{</nowiki>[[Template:pecahan|pecahan]]}}
::* <nowiki>{{sub}} → {{</nowiki>[[Template:subskrip|subskrip]]}}
::* <nowiki>{{sup}} → {{</nowiki>[[Template:superskrip|superskrip]]}}
::* <nowiki>{{su}} → {{</nowiki>[[Template:subsup|subsup]]}}
::* <nowiki>{{overline}} → {{</nowiki>[[Template:garis atas|garis atas]]}}
::* <nowiki>{{overset}} → {{</nowiki>[[Template:set atas|set atas]]}}
::* <nowiki>{{underset}} → {{</nowiki>[[Template:set bawah|set bawah]]}}
::Terima kasih banyak! :D [[User:OwlyKnight|OwlyKnight]] ([[User talk:OwlyKnight|talk]]) 09:01, 5 August 2026 (UTC)
538aa6a2qpmzofes2opdv3eonteddf0
Рэндэрынг мноства Мандэльброта на C++
0
55805
385913
385408
2026-08-04T18:04:05Z
Aokoroko
55658
/* Зыходны код C++ */
385913
wikitext
text/x-wiki
{{Language|be}} <span style="font-size:90%; color:#54595d;">Мовы курса:</span> [https://ru.wikiversity.org/wiki/Рендеринг_множества_Мандельброта_на_C%2B%2B 🇷🇺 Русский] • '''🇧🇾 Беларуская''' • [[Рендеринг множини Мандельброта на C++|🇺🇦 Українська]]
{| class="wikitable" style="float: right; margin: 0 0 1em 1em; width: 300px;"
|-
! colspan="2" | Курс «Рэндэрынг мноства Мандэльброта на C++»
|-
| '''Факультэт:''' || Інфармацыйныя тэхналогіі
|-
| '''Прэрэквізіты:''' || Веданне сінтаксісу C++ і камплексных лікаў
|-
| '''Патрабаванні пасля:''' || Навыкі аптымізацыі рэндэрынгу фракталаў
|-
| '''Выкладчык:''' || [[User:Aokoroko]]
|}
== Уводзіны ==
Дадзены практыкум змяшчае арыгінальны зыходны код на C++ для высокадакладнага рэндэрынгу фрагментаў мноства Мандэльброта з выкарыстаннем алгарытмаў аптымізацыі (уключаючы тэорыю абурэнняў) і глыбокага згладжвання (8x8 SSAA). Аўтар алгарытму і выяў: [[User:Aokoroko]].
== Ключавыя асаблівасці ==
* Разлік апорнай траекторыі на 5000 біт усяго адзін раз.
* Рэактыўны разлік мільярда пікселяў на апаратным double.
* Пры выкарыстанні лікаў з плаваючай коскай двайной дакладнасці (парадку 10⁻¹⁵) тэорыя абурэнняў дазваляе наблізіцца да ўзроўню 10⁻³⁰⁸ - не далей.
* Рэвалюцыйны алгарытм Reference Reset to Zero.
* Сапраўдны SSAA 8x8 для ідэальна згладжанага малюнка без аліасінгу.
* Паралелізм OpenMP для высокахуткаснага шматпаточнага рэндэрынгу.
== Зыходны код C++ ==
Ніжэй прадстаўлены зыходны код праграмы, які выкарыстоўваўся для генерацыі 100-мегапіксельных выбраных выяў на Вікісховішчы.
<syntaxhighlight lang="cpp">
#include <atomic>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <mpfr.h>
#include <omp.h>
using std::vector;
using std::min;
const char * CENTER_RE = "-1.99999543561201124623198345433951143502785679245726844745821388800402678499411681518036306219179273434395557574279985918047221291197081186140687781560831995";
const char * CENTER_IM = "-0.00000000000000000000000026198152173811047783694060060607013913873144250985383083459221663448338433592617272786772587281530484110756597337683912309313885172";
const char * VIEW_SIZE = "1.15e-119";
const int WIDTH = 2160;
const int HEIGHT = 2160;
const int AA = 8;
const int MAX_ITER = 50000;
const double ESCAPE_RADIUS_SQUARED = 50000.0;
const int PALETTE_FRAME = 200;
const char * OUTPUT_FILE = "Mandelbrot Set Image 112.bmp";
const mpfr_prec_t PRECISION_BITS = 1000;
struct Complex {
double re;
double im;
};
#pragma pack(push, 1)
struct BMPHeader {
uint16_t type{0x4D42};
uint32_t size{0};
uint32_t reserved{0};
uint32_t offBits{54};
uint32_t structSize{40};
int32_t width{0};
int32_t height{0};
uint16_t planes{1};
uint16_t bitCount{24};
uint32_t compression{0};
uint32_t sizeImage{0};
int32_t xPixelsPerMeter{2834};
int32_t yPixelsPerMeter{2834};
uint32_t colorsUsed{0};
uint32_t colorsImportant{0};
};
#pragma pack(pop)
int main() {
const double startTime = omp_get_wtime();
const long rawWidth = static_cast<long>(WIDTH) * AA;
const long rawHeight = static_cast<long>(HEIGHT) * AA;
mpfr_t centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp;
mpfr_inits2(PRECISION_BITS, centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
mpfr_set_str(centerRe, CENTER_RE, 10, MPFR_RNDN);
mpfr_set_str(centerIm, CENTER_IM, 10, MPFR_RNDN);
mpfr_set_str(viewSizeMp, VIEW_SIZE, 10, MPFR_RNDN);
const double sampleStep = mpfr_get_d(viewSizeMp, MPFR_RNDN) / rawWidth;
vector<Complex> referenceOrbit;
referenceOrbit.reserve(MAX_ITER + 200);
mpfr_set_ui(zReMp, 0, MPFR_RNDN);
mpfr_set_ui(zImMp, 0, MPFR_RNDN);
for (int iter = 0; iter <= MAX_ITER + 150; ++iter) {
Complex z{mpfr_get_d(zReMp, MPFR_RNDN), mpfr_get_d(zImMp, MPFR_RNDN)};
referenceOrbit.push_back(z);
if (z.re * z.re + z.im * z.im > ESCAPE_RADIUS_SQUARED && iter > MAX_ITER) {
break;
}
mpfr_mul(tmp1, zReMp, zImMp, MPFR_RNDN);
mpfr_sqr(tmp2, zReMp, MPFR_RNDN);
mpfr_sqr(zReMp, zImMp, MPFR_RNDN);
mpfr_sub(zReMp, tmp2, zReMp, MPFR_RNDN);
mpfr_add(zReMp, zReMp, centerRe, MPFR_RNDN);
mpfr_mul_2ui(tmp1, tmp1, 1, MPFR_RNDN);
mpfr_add(zImMp, tmp1, centerIm, MPFR_RNDN);
}
const int referenceLength = static_cast<int>(referenceOrbit.size());
mpfr_clears(centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
std::fprintf(stderr, "Reference orbit: %d points\n", referenceLength);
std::fprintf(stderr, "Precomputing skip100 matrices...\n");
vector<Complex> coeff_A(referenceLength, {1.0, 0.0});
vector<Complex> coeff_B(referenceLength, {0.0, 0.0});
vector<double> rad_R(referenceLength, 2.0);
#pragma omp parallel for
for (int i = 0; i < MAX_ITER; ++i) {
double min_r = 2.0;
for (int k = 0; k < 100; ++k) {
if (i + k >= referenceLength) break;
double r_re = referenceOrbit[i + k].re;
double r_im = referenceOrbit[i + k].im;
double abs_s = std::sqrt(r_re * r_re + r_im * r_im);
double aS = (abs_s < 2.0) ? abs_s : 0.0;
min_r = min(min_r, aS);
double next_A_re = 2.0 * (r_re * coeff_A[i].re - r_im * coeff_A[i].im);
double next_A_im = 2.0 * (r_re * coeff_A[i].im + r_im * coeff_A[i].re);
double next_B_re = 2.0 * (r_re * coeff_B[i].re - r_im * coeff_B[i].im) + 1.0;
double next_B_im = 2.0 * (r_re * coeff_B[i].im + r_im * coeff_B[i].re);
coeff_A[i].re = next_A_re; coeff_A[i].im = next_A_im;
coeff_B[i].re = next_B_re; coeff_B[i].im = next_B_im;
}
rad_R[i] = min_r;
}
const double PI = 3.14159265358979323846;
uint8_t palette[256][3];
for (int i = 0; i < 255; ++i) {
palette[i][0] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::cos(2.0 * PI * i / 255.0)));
palette[i][1] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::sin(2.0 * PI * i / 255.0)));
palette[i][2] = palette[i][1];
}
palette[255][0] = 255; palette[255][1] = 255; palette[255][2] = 255;
const int rowBytes = (WIDTH * 3 + 3) & ~3;
vector<uint8_t> image(static_cast<size_t>(rowBytes) * HEIGHT, 0);
std::atomic<int> completedRows{0};
const Complex * reference = referenceOrbit.data();
#pragma omp parallel for schedule(dynamic)
for (int y = 0; y < HEIGHT; ++y) {
uint8_t * row = image.data() + static_cast<size_t>(y) * rowBytes;
for (int x = 0; x < WIDTH; ++x) {
unsigned blueSum = 0; unsigned greenSum = 0; unsigned redSum = 0;
for (int sampleY = 0; sampleY < AA; ++sampleY) {
const double deltaCIm = (static_cast<long>(y) * AA + sampleY - rawHeight / 2) * sampleStep;
for (int sampleX = 0; sampleX < AA; ++sampleX) {
const double deltaCRe = (static_cast<long>(x) * AA + sampleX - rawWidth / 2) * sampleStep;
double deltaRe = 0.0; double deltaIm = 0.0;
double zRe = 0.0; double zIm = 0.0;
int referenceIndex = 0;
int iter = 0;
while (iter < MAX_ITER) {
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
break;
}
double eps_abs2 = deltaRe * deltaRe + deltaIm * deltaIm;
double limit_r2 = 1e-60 * rad_R[referenceIndex] * rad_R[referenceIndex];
if (eps_abs2 < limit_r2 && (referenceIndex + 100 < referenceLength - 1) && (iter + 100 < MAX_ITER)) {
double backup_deltaRe = deltaRe; double backup_deltaIm = deltaIm;
int backup_refIdx = referenceIndex; int backup_iter = iter;
double next_eps_re = (coeff_A[referenceIndex].re * deltaRe - coeff_A[referenceIndex].im * deltaIm) +
(coeff_B[referenceIndex].re * deltaCRe - coeff_B[referenceIndex].im * deltaCIm);
double next_eps_im = (coeff_A[referenceIndex].re * deltaIm + coeff_A[referenceIndex].im * deltaRe) +
(coeff_B[referenceIndex].re * deltaCIm + coeff_B[referenceIndex].im * deltaCRe);
deltaRe = next_eps_re; deltaIm = next_eps_im;
referenceIndex += 100; iter += 100;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
deltaRe = backup_deltaRe; deltaIm = backup_deltaIm;
referenceIndex = backup_refIdx; iter = backup_iter;
} else {
continue;
}
}
const double a = 2.0 * reference[referenceIndex].re + deltaRe;
const double b = 2.0 * reference[referenceIndex].im + deltaIm;
const double nextDeltaRe = a * deltaRe - b * deltaIm + deltaCRe;
deltaIm = a * deltaIm + b * deltaRe + deltaCIm;
deltaRe = nextDeltaRe;
++referenceIndex; ++iter;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm < deltaRe * deltaRe + deltaIm * deltaIm || referenceIndex == referenceLength - 1) {
deltaRe = zRe; deltaIm = zIm; referenceIndex = 0;
}
}
const int remaining = MAX_ITER - iter;
const uint8_t colorIndex = (remaining == 0) ? 255 : static_cast<uint8_t>(remaining % 254);
const int paletteIndex = (colorIndex == 255) ? 255 : (colorIndex - PALETTE_FRAME + 255) % 255;
blueSum += palette[paletteIndex][0];
greenSum += palette[paletteIndex][1];
redSum += palette[paletteIndex][2];
}
}
const int samples = AA * AA;
row[x * 3 + 0] = static_cast<uint8_t>(blueSum / samples);
row[x * 3 + 1] = static_cast<uint8_t>(greenSum / samples);
row[x * 3 + 2] = static_cast<uint8_t>(redSum / samples);
}
const int done = ++completedRows;
if (done % 50 == 0 || done == HEIGHT) {
std::fprintf(stderr, "\rProgress: %d/%d rows (%.1f%%)", done, HEIGHT, 100.0 * done / HEIGHT);
}
}
BMPHeader header;
header.width = WIDTH; header.height = HEIGHT;
header.sizeImage = static_cast<uint32_t>(image.size());
header.size = header.sizeImage + 54;
FILE * file = std::fopen(OUTPUT_FILE, "wb");
if (!file) { std::perror(OUTPUT_FILE); return 1; }
std::fwrite(&header, sizeof header, 1, file);
std::fwrite(image.data(), 1, image.size(), file);
std::fclose(file);
std::fprintf(stderr, "\nDone: \"%s\" saved in %.1f s\n", OUTPUT_FILE, omp_get_wtime() - startTime);
return 0;
}
</syntaxhighlight>
== Прыклады выяў ==
<gallery mode="packed" heights="200">
File:Mandelbrot Set Image 107.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
File:Mandelbrot Set Image 108.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
File:Mandelbrot Set Image 109.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
File:Mandelbrot Set Image 110.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
</gallery>
== Спасылкі ==
* [https://github.com/Divetoxx/Mandelbrot Афіцыйны рэпазіторый праекта Mandelbrot CLI на GitHub] — зыходны код, дакументацыя і гатовыя рэлізы праграмы рэндэрынгу.
* [https://rosettacode.org/wiki/Mandelbrot_set#Perturbation_Theory Прыклады аптымізацыі на Rosetta Code] — рэалізацыя тэорыі абурэнняў на C++ у глабальнай базе праграмных рашэнняў.
[[Category:be:Computer science]]
[[Category:BE]]
ts91g32ehpoq14h28m6umlfstk02op1
385916
385913
2026-08-04T18:22:38Z
Aokoroko
55658
/* Ключавыя асаблівасці */
385916
wikitext
text/x-wiki
{{Language|be}} <span style="font-size:90%; color:#54595d;">Мовы курса:</span> [https://ru.wikiversity.org/wiki/Рендеринг_множества_Мандельброта_на_C%2B%2B 🇷🇺 Русский] • '''🇧🇾 Беларуская''' • [[Рендеринг множини Мандельброта на C++|🇺🇦 Українська]]
{| class="wikitable" style="float: right; margin: 0 0 1em 1em; width: 300px;"
|-
! colspan="2" | Курс «Рэндэрынг мноства Мандэльброта на C++»
|-
| '''Факультэт:''' || Інфармацыйныя тэхналогіі
|-
| '''Прэрэквізіты:''' || Веданне сінтаксісу C++ і камплексных лікаў
|-
| '''Патрабаванні пасля:''' || Навыкі аптымізацыі рэндэрынгу фракталаў
|-
| '''Выкладчык:''' || [[User:Aokoroko]]
|}
== Уводзіны ==
Дадзены практыкум змяшчае арыгінальны зыходны код на C++ для высокадакладнага рэндэрынгу фрагментаў мноства Мандэльброта з выкарыстаннем алгарытмаў аптымізацыі (уключаючы тэорыю абурэнняў) і глыбокага згладжвання (8x8 SSAA). Аўтар алгарытму і выяў: [[User:Aokoroko]].
== Ключавыя асаблівасці ==
* Разлік апорнай траекторыі на 1000 біт усяго адзін раз.
* Рэактыўны разлік мільярда пікселяў на апаратным double.
* Разлік можна выканаць істотна хутчэй, калі выкарыстоўваць білінейную апраксімацыю.
* Пры выкарыстанні лікаў з плаваючай коскай двайной дакладнасці (парадку 10⁻¹⁵) тэорыя абурэнняў дазваляе наблізіцца да ўзроўню 10⁻³⁰⁸ - не далей.
* Рэвалюцыйны алгарытм Reference Reset to Zero.
* Сапраўдны SSAA 8x8 для ідэальна згладжанага малюнка без аліасінгу.
* Паралелізм OpenMP для высокахуткаснага шматпаточнага рэндэрынгу.
== Зыходны код C++ ==
Ніжэй прадстаўлены зыходны код праграмы, які выкарыстоўваўся для генерацыі 100-мегапіксельных выбраных выяў на Вікісховішчы.
<syntaxhighlight lang="cpp">
#include <atomic>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <mpfr.h>
#include <omp.h>
using std::vector;
using std::min;
const char * CENTER_RE = "-1.99999543561201124623198345433951143502785679245726844745821388800402678499411681518036306219179273434395557574279985918047221291197081186140687781560831995";
const char * CENTER_IM = "-0.00000000000000000000000026198152173811047783694060060607013913873144250985383083459221663448338433592617272786772587281530484110756597337683912309313885172";
const char * VIEW_SIZE = "1.15e-119";
const int WIDTH = 2160;
const int HEIGHT = 2160;
const int AA = 8;
const int MAX_ITER = 50000;
const double ESCAPE_RADIUS_SQUARED = 50000.0;
const int PALETTE_FRAME = 200;
const char * OUTPUT_FILE = "Mandelbrot Set Image 112.bmp";
const mpfr_prec_t PRECISION_BITS = 1000;
struct Complex {
double re;
double im;
};
#pragma pack(push, 1)
struct BMPHeader {
uint16_t type{0x4D42};
uint32_t size{0};
uint32_t reserved{0};
uint32_t offBits{54};
uint32_t structSize{40};
int32_t width{0};
int32_t height{0};
uint16_t planes{1};
uint16_t bitCount{24};
uint32_t compression{0};
uint32_t sizeImage{0};
int32_t xPixelsPerMeter{2834};
int32_t yPixelsPerMeter{2834};
uint32_t colorsUsed{0};
uint32_t colorsImportant{0};
};
#pragma pack(pop)
int main() {
const double startTime = omp_get_wtime();
const long rawWidth = static_cast<long>(WIDTH) * AA;
const long rawHeight = static_cast<long>(HEIGHT) * AA;
mpfr_t centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp;
mpfr_inits2(PRECISION_BITS, centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
mpfr_set_str(centerRe, CENTER_RE, 10, MPFR_RNDN);
mpfr_set_str(centerIm, CENTER_IM, 10, MPFR_RNDN);
mpfr_set_str(viewSizeMp, VIEW_SIZE, 10, MPFR_RNDN);
const double sampleStep = mpfr_get_d(viewSizeMp, MPFR_RNDN) / rawWidth;
vector<Complex> referenceOrbit;
referenceOrbit.reserve(MAX_ITER + 200);
mpfr_set_ui(zReMp, 0, MPFR_RNDN);
mpfr_set_ui(zImMp, 0, MPFR_RNDN);
for (int iter = 0; iter <= MAX_ITER + 150; ++iter) {
Complex z{mpfr_get_d(zReMp, MPFR_RNDN), mpfr_get_d(zImMp, MPFR_RNDN)};
referenceOrbit.push_back(z);
if (z.re * z.re + z.im * z.im > ESCAPE_RADIUS_SQUARED && iter > MAX_ITER) {
break;
}
mpfr_mul(tmp1, zReMp, zImMp, MPFR_RNDN);
mpfr_sqr(tmp2, zReMp, MPFR_RNDN);
mpfr_sqr(zReMp, zImMp, MPFR_RNDN);
mpfr_sub(zReMp, tmp2, zReMp, MPFR_RNDN);
mpfr_add(zReMp, zReMp, centerRe, MPFR_RNDN);
mpfr_mul_2ui(tmp1, tmp1, 1, MPFR_RNDN);
mpfr_add(zImMp, tmp1, centerIm, MPFR_RNDN);
}
const int referenceLength = static_cast<int>(referenceOrbit.size());
mpfr_clears(centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
std::fprintf(stderr, "Reference orbit: %d points\n", referenceLength);
std::fprintf(stderr, "Precomputing skip100 matrices...\n");
vector<Complex> coeff_A(referenceLength, {1.0, 0.0});
vector<Complex> coeff_B(referenceLength, {0.0, 0.0});
vector<double> rad_R(referenceLength, 2.0);
#pragma omp parallel for
for (int i = 0; i < MAX_ITER; ++i) {
double min_r = 2.0;
for (int k = 0; k < 100; ++k) {
if (i + k >= referenceLength) break;
double r_re = referenceOrbit[i + k].re;
double r_im = referenceOrbit[i + k].im;
double abs_s = std::sqrt(r_re * r_re + r_im * r_im);
double aS = (abs_s < 2.0) ? abs_s : 0.0;
min_r = min(min_r, aS);
double next_A_re = 2.0 * (r_re * coeff_A[i].re - r_im * coeff_A[i].im);
double next_A_im = 2.0 * (r_re * coeff_A[i].im + r_im * coeff_A[i].re);
double next_B_re = 2.0 * (r_re * coeff_B[i].re - r_im * coeff_B[i].im) + 1.0;
double next_B_im = 2.0 * (r_re * coeff_B[i].im + r_im * coeff_B[i].re);
coeff_A[i].re = next_A_re; coeff_A[i].im = next_A_im;
coeff_B[i].re = next_B_re; coeff_B[i].im = next_B_im;
}
rad_R[i] = min_r;
}
const double PI = 3.14159265358979323846;
uint8_t palette[256][3];
for (int i = 0; i < 255; ++i) {
palette[i][0] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::cos(2.0 * PI * i / 255.0)));
palette[i][1] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::sin(2.0 * PI * i / 255.0)));
palette[i][2] = palette[i][1];
}
palette[255][0] = 255; palette[255][1] = 255; palette[255][2] = 255;
const int rowBytes = (WIDTH * 3 + 3) & ~3;
vector<uint8_t> image(static_cast<size_t>(rowBytes) * HEIGHT, 0);
std::atomic<int> completedRows{0};
const Complex * reference = referenceOrbit.data();
#pragma omp parallel for schedule(dynamic)
for (int y = 0; y < HEIGHT; ++y) {
uint8_t * row = image.data() + static_cast<size_t>(y) * rowBytes;
for (int x = 0; x < WIDTH; ++x) {
unsigned blueSum = 0; unsigned greenSum = 0; unsigned redSum = 0;
for (int sampleY = 0; sampleY < AA; ++sampleY) {
const double deltaCIm = (static_cast<long>(y) * AA + sampleY - rawHeight / 2) * sampleStep;
for (int sampleX = 0; sampleX < AA; ++sampleX) {
const double deltaCRe = (static_cast<long>(x) * AA + sampleX - rawWidth / 2) * sampleStep;
double deltaRe = 0.0; double deltaIm = 0.0;
double zRe = 0.0; double zIm = 0.0;
int referenceIndex = 0;
int iter = 0;
while (iter < MAX_ITER) {
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
break;
}
double eps_abs2 = deltaRe * deltaRe + deltaIm * deltaIm;
double limit_r2 = 1e-60 * rad_R[referenceIndex] * rad_R[referenceIndex];
if (eps_abs2 < limit_r2 && (referenceIndex + 100 < referenceLength - 1) && (iter + 100 < MAX_ITER)) {
double backup_deltaRe = deltaRe; double backup_deltaIm = deltaIm;
int backup_refIdx = referenceIndex; int backup_iter = iter;
double next_eps_re = (coeff_A[referenceIndex].re * deltaRe - coeff_A[referenceIndex].im * deltaIm) +
(coeff_B[referenceIndex].re * deltaCRe - coeff_B[referenceIndex].im * deltaCIm);
double next_eps_im = (coeff_A[referenceIndex].re * deltaIm + coeff_A[referenceIndex].im * deltaRe) +
(coeff_B[referenceIndex].re * deltaCIm + coeff_B[referenceIndex].im * deltaCRe);
deltaRe = next_eps_re; deltaIm = next_eps_im;
referenceIndex += 100; iter += 100;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
deltaRe = backup_deltaRe; deltaIm = backup_deltaIm;
referenceIndex = backup_refIdx; iter = backup_iter;
} else {
continue;
}
}
const double a = 2.0 * reference[referenceIndex].re + deltaRe;
const double b = 2.0 * reference[referenceIndex].im + deltaIm;
const double nextDeltaRe = a * deltaRe - b * deltaIm + deltaCRe;
deltaIm = a * deltaIm + b * deltaRe + deltaCIm;
deltaRe = nextDeltaRe;
++referenceIndex; ++iter;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm < deltaRe * deltaRe + deltaIm * deltaIm || referenceIndex == referenceLength - 1) {
deltaRe = zRe; deltaIm = zIm; referenceIndex = 0;
}
}
const int remaining = MAX_ITER - iter;
const uint8_t colorIndex = (remaining == 0) ? 255 : static_cast<uint8_t>(remaining % 254);
const int paletteIndex = (colorIndex == 255) ? 255 : (colorIndex - PALETTE_FRAME + 255) % 255;
blueSum += palette[paletteIndex][0];
greenSum += palette[paletteIndex][1];
redSum += palette[paletteIndex][2];
}
}
const int samples = AA * AA;
row[x * 3 + 0] = static_cast<uint8_t>(blueSum / samples);
row[x * 3 + 1] = static_cast<uint8_t>(greenSum / samples);
row[x * 3 + 2] = static_cast<uint8_t>(redSum / samples);
}
const int done = ++completedRows;
if (done % 50 == 0 || done == HEIGHT) {
std::fprintf(stderr, "\rProgress: %d/%d rows (%.1f%%)", done, HEIGHT, 100.0 * done / HEIGHT);
}
}
BMPHeader header;
header.width = WIDTH; header.height = HEIGHT;
header.sizeImage = static_cast<uint32_t>(image.size());
header.size = header.sizeImage + 54;
FILE * file = std::fopen(OUTPUT_FILE, "wb");
if (!file) { std::perror(OUTPUT_FILE); return 1; }
std::fwrite(&header, sizeof header, 1, file);
std::fwrite(image.data(), 1, image.size(), file);
std::fclose(file);
std::fprintf(stderr, "\nDone: \"%s\" saved in %.1f s\n", OUTPUT_FILE, omp_get_wtime() - startTime);
return 0;
}
</syntaxhighlight>
== Прыклады выяў ==
<gallery mode="packed" heights="200">
File:Mandelbrot Set Image 107.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
File:Mandelbrot Set Image 108.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
File:Mandelbrot Set Image 109.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
File:Mandelbrot Set Image 110.png|Фрагмент мноства, тэорыя абурэнняў. Адрознівальная здольнасць 10000 x 10000 пікселяў.
</gallery>
== Спасылкі ==
* [https://github.com/Divetoxx/Mandelbrot Афіцыйны рэпазіторый праекта Mandelbrot CLI на GitHub] — зыходны код, дакументацыя і гатовыя рэлізы праграмы рэндэрынгу.
* [https://rosettacode.org/wiki/Mandelbrot_set#Perturbation_Theory Прыклады аптымізацыі на Rosetta Code] — рэалізацыя тэорыі абурэнняў на C++ у глабальнай базе праграмных рашэнняў.
[[Category:be:Computer science]]
[[Category:BE]]
6fdy1sr7bx0o2c8xofe0dbs4j8qpukf
Рендеринг множини Мандельброта на C++
0
55806
385912
385409
2026-08-04T18:03:32Z
Aokoroko
55658
/* Вихідний код C++ */
385912
wikitext
text/x-wiki
{{Language|uk}} <span style="font-size:90%; color:#54595d;">Мови курсу:</span> [https://ru.wikiversity.org/wiki/Рендеринг_множества_Мандельброта_на_C%2B%2B 🇷🇺 Русский] • [[Рэндэрынг мноства Мандэльброта на C++|🇧🇾 Беларуская]] • '''🇺🇦 Українська'''
{| class="wikitable" style="float: right; margin: 0 0 1em 1em; width: 300px;"
|-
! colspan="2" | Курс «Рендеринг множини Мандельброта на C++»
|-
| '''Факультет:''' || Інформаційні технології
|-
| '''Пререквізити:''' || Знання синтаксису C++ та комплексних чисел
|-
| '''Постреквізити:''' || Навички оптимізації рендерингу фракталів
|-
| '''Викладач:''' || [[User:Aokoroko]]
|}
== Вступ ==
Даний практикум містить оригінальний вихідний код на C++ для високоточного рендерингу фрагментів множини Мандельброта з використанням алгоритмів оптимізації (включаючи теорію збурень) та глибокого згладжування (8x8 SSAA). Автор алгоритму та зображень: [[User:Aokoroko]].
== Ключові особливості ==
* Розрахунок опорної траєкторії на 5000 біт усього один раз.
* Реактивний розрахунок мільярда пікселів на апаратному double.
* При використанні чисел із плаваючою комою подвійної точності (порядку 10⁻¹⁵) теорія збурень дозволяє наблизитися до рівня 10⁻³⁰⁸ - не далі.
* Революційний алгоритм Reference Reset to Zero.
* Справжній SSAA 8x8 для ідеально згладженого зображення без аліасингу.
* Паралелізм OpenMP для високошвидкісного багатопотокового рендерингу.
== Вихідний код C++ ==
Ниже представлений вихідний код програми, що використовувався для генерації 100-мегапіксельних вибраних зображень на Вікісховищі.
<syntaxhighlight lang="cpp">
#include <atomic>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <mpfr.h>
#include <omp.h>
using std::vector;
using std::min;
const char * CENTER_RE = "-1.99999543561201124623198345433951143502785679245726844745821388800402678499411681518036306219179273434395557574279985918047221291197081186140687781560831995";
const char * CENTER_IM = "-0.00000000000000000000000026198152173811047783694060060607013913873144250985383083459221663448338433592617272786772587281530484110756597337683912309313885172";
const char * VIEW_SIZE = "1.15e-119";
const int WIDTH = 2160;
const int HEIGHT = 2160;
const int AA = 8;
const int MAX_ITER = 50000;
const double ESCAPE_RADIUS_SQUARED = 50000.0;
const int PALETTE_FRAME = 200;
const char * OUTPUT_FILE = "Mandelbrot Set Image 112.bmp";
const mpfr_prec_t PRECISION_BITS = 1000;
struct Complex {
double re;
double im;
};
#pragma pack(push, 1)
struct BMPHeader {
uint16_t type{0x4D42};
uint32_t size{0};
uint32_t reserved{0};
uint32_t offBits{54};
uint32_t structSize{40};
int32_t width{0};
int32_t height{0};
uint16_t planes{1};
uint16_t bitCount{24};
uint32_t compression{0};
uint32_t sizeImage{0};
int32_t xPixelsPerMeter{2834};
int32_t yPixelsPerMeter{2834};
uint32_t colorsUsed{0};
uint32_t colorsImportant{0};
};
#pragma pack(pop)
int main() {
const double startTime = omp_get_wtime();
const long rawWidth = static_cast<long>(WIDTH) * AA;
const long rawHeight = static_cast<long>(HEIGHT) * AA;
mpfr_t centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp;
mpfr_inits2(PRECISION_BITS, centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
mpfr_set_str(centerRe, CENTER_RE, 10, MPFR_RNDN);
mpfr_set_str(centerIm, CENTER_IM, 10, MPFR_RNDN);
mpfr_set_str(viewSizeMp, VIEW_SIZE, 10, MPFR_RNDN);
const double sampleStep = mpfr_get_d(viewSizeMp, MPFR_RNDN) / rawWidth;
vector<Complex> referenceOrbit;
referenceOrbit.reserve(MAX_ITER + 200);
mpfr_set_ui(zReMp, 0, MPFR_RNDN);
mpfr_set_ui(zImMp, 0, MPFR_RNDN);
for (int iter = 0; iter <= MAX_ITER + 150; ++iter) {
Complex z{mpfr_get_d(zReMp, MPFR_RNDN), mpfr_get_d(zImMp, MPFR_RNDN)};
referenceOrbit.push_back(z);
if (z.re * z.re + z.im * z.im > ESCAPE_RADIUS_SQUARED && iter > MAX_ITER) {
break;
}
mpfr_mul(tmp1, zReMp, zImMp, MPFR_RNDN);
mpfr_sqr(tmp2, zReMp, MPFR_RNDN);
mpfr_sqr(zReMp, zImMp, MPFR_RNDN);
mpfr_sub(zReMp, tmp2, zReMp, MPFR_RNDN);
mpfr_add(zReMp, zReMp, centerRe, MPFR_RNDN);
mpfr_mul_2ui(tmp1, tmp1, 1, MPFR_RNDN);
mpfr_add(zImMp, tmp1, centerIm, MPFR_RNDN);
}
const int referenceLength = static_cast<int>(referenceOrbit.size());
mpfr_clears(centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
std::fprintf(stderr, "Reference orbit: %d points\n", referenceLength);
std::fprintf(stderr, "Precomputing skip100 matrices...\n");
vector<Complex> coeff_A(referenceLength, {1.0, 0.0});
vector<Complex> coeff_B(referenceLength, {0.0, 0.0});
vector<double> rad_R(referenceLength, 2.0);
#pragma omp parallel for
for (int i = 0; i < MAX_ITER; ++i) {
double min_r = 2.0;
for (int k = 0; k < 100; ++k) {
if (i + k >= referenceLength) break;
double r_re = referenceOrbit[i + k].re;
double r_im = referenceOrbit[i + k].im;
double abs_s = std::sqrt(r_re * r_re + r_im * r_im);
double aS = (abs_s < 2.0) ? abs_s : 0.0;
min_r = min(min_r, aS);
double next_A_re = 2.0 * (r_re * coeff_A[i].re - r_im * coeff_A[i].im);
double next_A_im = 2.0 * (r_re * coeff_A[i].im + r_im * coeff_A[i].re);
double next_B_re = 2.0 * (r_re * coeff_B[i].re - r_im * coeff_B[i].im) + 1.0;
double next_B_im = 2.0 * (r_re * coeff_B[i].im + r_im * coeff_B[i].re);
coeff_A[i].re = next_A_re; coeff_A[i].im = next_A_im;
coeff_B[i].re = next_B_re; coeff_B[i].im = next_B_im;
}
rad_R[i] = min_r;
}
const double PI = 3.14159265358979323846;
uint8_t palette[256][3];
for (int i = 0; i < 255; ++i) {
palette[i][0] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::cos(2.0 * PI * i / 255.0)));
palette[i][1] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::sin(2.0 * PI * i / 255.0)));
palette[i][2] = palette[i][1];
}
palette[255][0] = 255; palette[255][1] = 255; palette[255][2] = 255;
const int rowBytes = (WIDTH * 3 + 3) & ~3;
vector<uint8_t> image(static_cast<size_t>(rowBytes) * HEIGHT, 0);
std::atomic<int> completedRows{0};
const Complex * reference = referenceOrbit.data();
#pragma omp parallel for schedule(dynamic)
for (int y = 0; y < HEIGHT; ++y) {
uint8_t * row = image.data() + static_cast<size_t>(y) * rowBytes;
for (int x = 0; x < WIDTH; ++x) {
unsigned blueSum = 0; unsigned greenSum = 0; unsigned redSum = 0;
for (int sampleY = 0; sampleY < AA; ++sampleY) {
const double deltaCIm = (static_cast<long>(y) * AA + sampleY - rawHeight / 2) * sampleStep;
for (int sampleX = 0; sampleX < AA; ++sampleX) {
const double deltaCRe = (static_cast<long>(x) * AA + sampleX - rawWidth / 2) * sampleStep;
double deltaRe = 0.0; double deltaIm = 0.0;
double zRe = 0.0; double zIm = 0.0;
int referenceIndex = 0;
int iter = 0;
while (iter < MAX_ITER) {
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
break;
}
double eps_abs2 = deltaRe * deltaRe + deltaIm * deltaIm;
double limit_r2 = 1e-60 * rad_R[referenceIndex] * rad_R[referenceIndex];
if (eps_abs2 < limit_r2 && (referenceIndex + 100 < referenceLength - 1) && (iter + 100 < MAX_ITER)) {
double backup_deltaRe = deltaRe; double backup_deltaIm = deltaIm;
int backup_refIdx = referenceIndex; int backup_iter = iter;
double next_eps_re = (coeff_A[referenceIndex].re * deltaRe - coeff_A[referenceIndex].im * deltaIm) +
(coeff_B[referenceIndex].re * deltaCRe - coeff_B[referenceIndex].im * deltaCIm);
double next_eps_im = (coeff_A[referenceIndex].re * deltaIm + coeff_A[referenceIndex].im * deltaRe) +
(coeff_B[referenceIndex].re * deltaCIm + coeff_B[referenceIndex].im * deltaCRe);
deltaRe = next_eps_re; deltaIm = next_eps_im;
referenceIndex += 100; iter += 100;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
deltaRe = backup_deltaRe; deltaIm = backup_deltaIm;
referenceIndex = backup_refIdx; iter = backup_iter;
} else {
continue;
}
}
const double a = 2.0 * reference[referenceIndex].re + deltaRe;
const double b = 2.0 * reference[referenceIndex].im + deltaIm;
const double nextDeltaRe = a * deltaRe - b * deltaIm + deltaCRe;
deltaIm = a * deltaIm + b * deltaRe + deltaCIm;
deltaRe = nextDeltaRe;
++referenceIndex; ++iter;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm < deltaRe * deltaRe + deltaIm * deltaIm || referenceIndex == referenceLength - 1) {
deltaRe = zRe; deltaIm = zIm; referenceIndex = 0;
}
}
const int remaining = MAX_ITER - iter;
const uint8_t colorIndex = (remaining == 0) ? 255 : static_cast<uint8_t>(remaining % 254);
const int paletteIndex = (colorIndex == 255) ? 255 : (colorIndex - PALETTE_FRAME + 255) % 255;
blueSum += palette[paletteIndex][0];
greenSum += palette[paletteIndex][1];
redSum += palette[paletteIndex][2];
}
}
const int samples = AA * AA;
row[x * 3 + 0] = static_cast<uint8_t>(blueSum / samples);
row[x * 3 + 1] = static_cast<uint8_t>(greenSum / samples);
row[x * 3 + 2] = static_cast<uint8_t>(redSum / samples);
}
const int done = ++completedRows;
if (done % 50 == 0 || done == HEIGHT) {
std::fprintf(stderr, "\rProgress: %d/%d rows (%.1f%%)", done, HEIGHT, 100.0 * done / HEIGHT);
}
}
BMPHeader header;
header.width = WIDTH; header.height = HEIGHT;
header.sizeImage = static_cast<uint32_t>(image.size());
header.size = header.sizeImage + 54;
FILE * file = std::fopen(OUTPUT_FILE, "wb");
if (!file) { std::perror(OUTPUT_FILE); return 1; }
std::fwrite(&header, sizeof header, 1, file);
std::fwrite(image.data(), 1, image.size(), file);
std::fclose(file);
std::fprintf(stderr, "\nDone: \"%s\" saved in %.1f s\n", OUTPUT_FILE, omp_get_wtime() - startTime);
return 0;
}
</syntaxhighlight>
== Приклади зображень ==
<gallery mode="packed" heights="200">
File:Mandelbrot Set Image 107.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
File:Mandelbrot Set Image 108.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
File:Mandelbrot Set Image 109.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
File:Mandelbrot Set Image 110.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
</gallery>
== Посилання ==
* [https://github.com/Divetoxx/Mandelbrot Офіційний репозиторій проєкту Mandelbrot CLI на GitHub] — вихідний код, документація та готові релізи програми рендерингу.
* [https://rosettacode.org/wiki/Mandelbrot_set#Perturbation_Theory Приклади оптимізації на Rosetta Code] — реалізацыя теорії збурень на C++ у глобальній базі програмних рішень.
[[Category:uk:Computer science]]
[[Category:UK]]
3k78zxd69vfq555wvnvzj1ru16difd3
385914
385912
2026-08-04T18:21:00Z
Aokoroko
55658
/* Ключові особливості */
385914
wikitext
text/x-wiki
{{Language|uk}} <span style="font-size:90%; color:#54595d;">Мови курсу:</span> [https://ru.wikiversity.org/wiki/Рендеринг_множества_Мандельброта_на_C%2B%2B 🇷🇺 Русский] • [[Рэндэрынг мноства Мандэльброта на C++|🇧🇾 Беларуская]] • '''🇺🇦 Українська'''
{| class="wikitable" style="float: right; margin: 0 0 1em 1em; width: 300px;"
|-
! colspan="2" | Курс «Рендеринг множини Мандельброта на C++»
|-
| '''Факультет:''' || Інформаційні технології
|-
| '''Пререквізити:''' || Знання синтаксису C++ та комплексних чисел
|-
| '''Постреквізити:''' || Навички оптимізації рендерингу фракталів
|-
| '''Викладач:''' || [[User:Aokoroko]]
|}
== Вступ ==
Даний практикум містить оригінальний вихідний код на C++ для високоточного рендерингу фрагментів множини Мандельброта з використанням алгоритмів оптимізації (включаючи теорію збурень) та глибокого згладжування (8x8 SSAA). Автор алгоритму та зображень: [[User:Aokoroko]].
== Ключові особливості ==
* Розрахунок опорної траєкторії на 1000 біт усього один раз.
* Реактивний розрахунок мільярда пікселів на апаратному double.
* Розрахунок можна виконати суттєво швидше, якщо використовувати білінійну апроксимацію.
* При використанні чисел із плаваючою комою подвійної точності (порядку 10⁻¹⁵) теорія збурень дозволяє наблизитися до рівня 10⁻³⁰⁸ - не далі.
* Революційний алгоритм Reference Reset to Zero.
* Справжній SSAA 8x8 для ідеально згладженого зображення без аліасингу.
* Паралелізм OpenMP для високошвидкісного багатопотокового рендерингу.
== Вихідний код C++ ==
Ниже представлений вихідний код програми, що використовувався для генерації 100-мегапіксельних вибраних зображень на Вікісховищі.
<syntaxhighlight lang="cpp">
#include <atomic>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <mpfr.h>
#include <omp.h>
using std::vector;
using std::min;
const char * CENTER_RE = "-1.99999543561201124623198345433951143502785679245726844745821388800402678499411681518036306219179273434395557574279985918047221291197081186140687781560831995";
const char * CENTER_IM = "-0.00000000000000000000000026198152173811047783694060060607013913873144250985383083459221663448338433592617272786772587281530484110756597337683912309313885172";
const char * VIEW_SIZE = "1.15e-119";
const int WIDTH = 2160;
const int HEIGHT = 2160;
const int AA = 8;
const int MAX_ITER = 50000;
const double ESCAPE_RADIUS_SQUARED = 50000.0;
const int PALETTE_FRAME = 200;
const char * OUTPUT_FILE = "Mandelbrot Set Image 112.bmp";
const mpfr_prec_t PRECISION_BITS = 1000;
struct Complex {
double re;
double im;
};
#pragma pack(push, 1)
struct BMPHeader {
uint16_t type{0x4D42};
uint32_t size{0};
uint32_t reserved{0};
uint32_t offBits{54};
uint32_t structSize{40};
int32_t width{0};
int32_t height{0};
uint16_t planes{1};
uint16_t bitCount{24};
uint32_t compression{0};
uint32_t sizeImage{0};
int32_t xPixelsPerMeter{2834};
int32_t yPixelsPerMeter{2834};
uint32_t colorsUsed{0};
uint32_t colorsImportant{0};
};
#pragma pack(pop)
int main() {
const double startTime = omp_get_wtime();
const long rawWidth = static_cast<long>(WIDTH) * AA;
const long rawHeight = static_cast<long>(HEIGHT) * AA;
mpfr_t centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp;
mpfr_inits2(PRECISION_BITS, centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
mpfr_set_str(centerRe, CENTER_RE, 10, MPFR_RNDN);
mpfr_set_str(centerIm, CENTER_IM, 10, MPFR_RNDN);
mpfr_set_str(viewSizeMp, VIEW_SIZE, 10, MPFR_RNDN);
const double sampleStep = mpfr_get_d(viewSizeMp, MPFR_RNDN) / rawWidth;
vector<Complex> referenceOrbit;
referenceOrbit.reserve(MAX_ITER + 200);
mpfr_set_ui(zReMp, 0, MPFR_RNDN);
mpfr_set_ui(zImMp, 0, MPFR_RNDN);
for (int iter = 0; iter <= MAX_ITER + 150; ++iter) {
Complex z{mpfr_get_d(zReMp, MPFR_RNDN), mpfr_get_d(zImMp, MPFR_RNDN)};
referenceOrbit.push_back(z);
if (z.re * z.re + z.im * z.im > ESCAPE_RADIUS_SQUARED && iter > MAX_ITER) {
break;
}
mpfr_mul(tmp1, zReMp, zImMp, MPFR_RNDN);
mpfr_sqr(tmp2, zReMp, MPFR_RNDN);
mpfr_sqr(zReMp, zImMp, MPFR_RNDN);
mpfr_sub(zReMp, tmp2, zReMp, MPFR_RNDN);
mpfr_add(zReMp, zReMp, centerRe, MPFR_RNDN);
mpfr_mul_2ui(tmp1, tmp1, 1, MPFR_RNDN);
mpfr_add(zImMp, tmp1, centerIm, MPFR_RNDN);
}
const int referenceLength = static_cast<int>(referenceOrbit.size());
mpfr_clears(centerRe, centerIm, zReMp, zImMp, tmp1, tmp2, viewSizeMp, static_cast<mpfr_ptr>(nullptr));
std::fprintf(stderr, "Reference orbit: %d points\n", referenceLength);
std::fprintf(stderr, "Precomputing skip100 matrices...\n");
vector<Complex> coeff_A(referenceLength, {1.0, 0.0});
vector<Complex> coeff_B(referenceLength, {0.0, 0.0});
vector<double> rad_R(referenceLength, 2.0);
#pragma omp parallel for
for (int i = 0; i < MAX_ITER; ++i) {
double min_r = 2.0;
for (int k = 0; k < 100; ++k) {
if (i + k >= referenceLength) break;
double r_re = referenceOrbit[i + k].re;
double r_im = referenceOrbit[i + k].im;
double abs_s = std::sqrt(r_re * r_re + r_im * r_im);
double aS = (abs_s < 2.0) ? abs_s : 0.0;
min_r = min(min_r, aS);
double next_A_re = 2.0 * (r_re * coeff_A[i].re - r_im * coeff_A[i].im);
double next_A_im = 2.0 * (r_re * coeff_A[i].im + r_im * coeff_A[i].re);
double next_B_re = 2.0 * (r_re * coeff_B[i].re - r_im * coeff_B[i].im) + 1.0;
double next_B_im = 2.0 * (r_re * coeff_B[i].im + r_im * coeff_B[i].re);
coeff_A[i].re = next_A_re; coeff_A[i].im = next_A_im;
coeff_B[i].re = next_B_re; coeff_B[i].im = next_B_im;
}
rad_R[i] = min_r;
}
const double PI = 3.14159265358979323846;
uint8_t palette[256][3];
for (int i = 0; i < 255; ++i) {
palette[i][0] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::cos(2.0 * PI * i / 255.0)));
palette[i][1] = static_cast<uint8_t>(std::lround(127.0 + 127.0 * std::sin(2.0 * PI * i / 255.0)));
palette[i][2] = palette[i][1];
}
palette[255][0] = 255; palette[255][1] = 255; palette[255][2] = 255;
const int rowBytes = (WIDTH * 3 + 3) & ~3;
vector<uint8_t> image(static_cast<size_t>(rowBytes) * HEIGHT, 0);
std::atomic<int> completedRows{0};
const Complex * reference = referenceOrbit.data();
#pragma omp parallel for schedule(dynamic)
for (int y = 0; y < HEIGHT; ++y) {
uint8_t * row = image.data() + static_cast<size_t>(y) * rowBytes;
for (int x = 0; x < WIDTH; ++x) {
unsigned blueSum = 0; unsigned greenSum = 0; unsigned redSum = 0;
for (int sampleY = 0; sampleY < AA; ++sampleY) {
const double deltaCIm = (static_cast<long>(y) * AA + sampleY - rawHeight / 2) * sampleStep;
for (int sampleX = 0; sampleX < AA; ++sampleX) {
const double deltaCRe = (static_cast<long>(x) * AA + sampleX - rawWidth / 2) * sampleStep;
double deltaRe = 0.0; double deltaIm = 0.0;
double zRe = 0.0; double zIm = 0.0;
int referenceIndex = 0;
int iter = 0;
while (iter < MAX_ITER) {
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
break;
}
double eps_abs2 = deltaRe * deltaRe + deltaIm * deltaIm;
double limit_r2 = 1e-60 * rad_R[referenceIndex] * rad_R[referenceIndex];
if (eps_abs2 < limit_r2 && (referenceIndex + 100 < referenceLength - 1) && (iter + 100 < MAX_ITER)) {
double backup_deltaRe = deltaRe; double backup_deltaIm = deltaIm;
int backup_refIdx = referenceIndex; int backup_iter = iter;
double next_eps_re = (coeff_A[referenceIndex].re * deltaRe - coeff_A[referenceIndex].im * deltaIm) +
(coeff_B[referenceIndex].re * deltaCRe - coeff_B[referenceIndex].im * deltaCIm);
double next_eps_im = (coeff_A[referenceIndex].re * deltaIm + coeff_A[referenceIndex].im * deltaRe) +
(coeff_B[referenceIndex].re * deltaCIm + coeff_B[referenceIndex].im * deltaCRe);
deltaRe = next_eps_re; deltaIm = next_eps_im;
referenceIndex += 100; iter += 100;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm >= ESCAPE_RADIUS_SQUARED) {
deltaRe = backup_deltaRe; deltaIm = backup_deltaIm;
referenceIndex = backup_refIdx; iter = backup_iter;
} else {
continue;
}
}
const double a = 2.0 * reference[referenceIndex].re + deltaRe;
const double b = 2.0 * reference[referenceIndex].im + deltaIm;
const double nextDeltaRe = a * deltaRe - b * deltaIm + deltaCRe;
deltaIm = a * deltaIm + b * deltaRe + deltaCIm;
deltaRe = nextDeltaRe;
++referenceIndex; ++iter;
zRe = reference[referenceIndex].re + deltaRe;
zIm = reference[referenceIndex].im + deltaIm;
if (zRe * zRe + zIm * zIm < deltaRe * deltaRe + deltaIm * deltaIm || referenceIndex == referenceLength - 1) {
deltaRe = zRe; deltaIm = zIm; referenceIndex = 0;
}
}
const int remaining = MAX_ITER - iter;
const uint8_t colorIndex = (remaining == 0) ? 255 : static_cast<uint8_t>(remaining % 254);
const int paletteIndex = (colorIndex == 255) ? 255 : (colorIndex - PALETTE_FRAME + 255) % 255;
blueSum += palette[paletteIndex][0];
greenSum += palette[paletteIndex][1];
redSum += palette[paletteIndex][2];
}
}
const int samples = AA * AA;
row[x * 3 + 0] = static_cast<uint8_t>(blueSum / samples);
row[x * 3 + 1] = static_cast<uint8_t>(greenSum / samples);
row[x * 3 + 2] = static_cast<uint8_t>(redSum / samples);
}
const int done = ++completedRows;
if (done % 50 == 0 || done == HEIGHT) {
std::fprintf(stderr, "\rProgress: %d/%d rows (%.1f%%)", done, HEIGHT, 100.0 * done / HEIGHT);
}
}
BMPHeader header;
header.width = WIDTH; header.height = HEIGHT;
header.sizeImage = static_cast<uint32_t>(image.size());
header.size = header.sizeImage + 54;
FILE * file = std::fopen(OUTPUT_FILE, "wb");
if (!file) { std::perror(OUTPUT_FILE); return 1; }
std::fwrite(&header, sizeof header, 1, file);
std::fwrite(image.data(), 1, image.size(), file);
std::fclose(file);
std::fprintf(stderr, "\nDone: \"%s\" saved in %.1f s\n", OUTPUT_FILE, omp_get_wtime() - startTime);
return 0;
}
</syntaxhighlight>
== Приклади зображень ==
<gallery mode="packed" heights="200">
File:Mandelbrot Set Image 107.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
File:Mandelbrot Set Image 108.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
File:Mandelbrot Set Image 109.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
File:Mandelbrot Set Image 110.png|Фрагмент множини, теорія збурень. Роздільна здатність 10000 x 10000 пікселів.
</gallery>
== Посилання ==
* [https://github.com/Divetoxx/Mandelbrot Офіційний репозиторій проєкту Mandelbrot CLI на GitHub] — вихідний код, документація та готові релізи програми рендерингу.
* [https://rosettacode.org/wiki/Mandelbrot_set#Perturbation_Theory Приклади оптимізації на Rosetta Code] — реалізацыя теорії збурень на C++ у глобальній базі програмних рішень.
[[Category:uk:Computer science]]
[[Category:UK]]
6lznnp2cyzypsd9dej65uhjmp1bnsdy
El cos dels nombres reals Bat
0
55864
385915
385907
2026-08-04T18:21:57Z
Profev
36331
+
385915
wikitext
text/x-wiki
{|align="right"
|<span style="font-size:800%"><math>\mathbb{R}</math></span>
|}
Secció on es treballen els '''nombres reals''' amb una profunditat orientada al batxillerat.
== Introducció ==
'''Definició:''' Un '''conjunt''' <math>A</math> és una agrupació d'elements, el seu contingut es defineix amb claus, com per exemple:
::<math>A=\Big\{\;3,\;\tfrac{4}{7}, \;\sqrt{2}\; \Big\}.</math>
:Per detallar que aquest conjunt conté cada element de la seva definició utilitzarem el símbol de pertinença <math>\in</math> i escriurem:
:::<math>3\in A,\;\;</math> <math>\tfrac{4}{7}\in A\;\;</math> 𝓸 <math>\;\;\sqrt{2}\in A</math>
:Per escriure que dos conjunts <math>A</math> i <math>B</math> són iguals i, per tant, tenen els mateixos elements, escriurem <math>A=B.</math>
:Per detallar que un conjunt <math>A</math> conté tots els elements d'un altre conjunt <math>B</math> però no són iguals escriurem <math>A\supset B</math> 𝓸 <math>B\subset A</math>
Si no es recorden els símbols, sempre es pot explicar verbalment i també s'accepta.
== Els nombres real ==
Els nombres reals, <math>\mathbb{R},</math> és un conjunt que conté tots els conjunts de nombres vistos fins ara.
:<math>\mathbb{R}\supset\mathbb{Q}\supset\mathbb{Z}\supset\mathbb{N}</math>
De fet es considera que els nombres reals són els nombres racionals junts amb els nombres irracionals.
:<math>\mathbb{R}=\mathbb{Q}\cup\mathbb{I}</math>
=== Propietat ===
'''Propietat:''' Els nombres reals són un '''cos''' si:
1) Té la operació binària suma on donats <math>a,b,c\in\mathbb{R}</math> llavors:
:a) La operació suma és '''interna''', és a dir que:
::Per a qualsevol <math>a</math> i <math>b</math> compleix que <math>(a+b)\in\mathbb{R}.</math>
:b) Té la propietat '''associativa''', és a dir que:
::Per a qualsevol <math>a,\; b</math> i <math>c</math> compleix que <math>(a+b)+c=a+(b+c).</math>
::'''Notació''': escriurem simplement <math>a+b+c.</math>
:c) Té la propietat '''commutativa''', és a dir que:
::Per a qualsevol <math>a</math> i <math>b</math> compleix que <math>a+b=b+a.</math>
:d) Té un únic element '''neutre''' <math>e\in\mathbb{R}</math> per a la suma, és a dir que:
::Per a qualsevol <math>a\in\mathbb{R}</math> compleix que <math>a+e=a.</math>
::'''Notació''': es diu zero i s'escriu com <math>e=0.</math>
:e) Cada element té un únic element '''invers''' per la suma, és a dir que:
::Si <math>a\in\mathbb{R}</math> llavors existeix un únic <math>b\in\mathbb{R}</math> tal que <math>a+b=0.</math>
::'''Notació''': es diu el negatiu i s'escriu com <math>b=-a.</math>
::'''Notació''': es pot escriure <math>a+(-a)=a-a.</math>
2) Té la operació binària multiplicació on donats <math>a,b,c\in\mathbb{R}</math> llavors:
:a) La operació multiplicació és '''interna''', és a dir que:
::Per a qualsevol <math>a</math> i <math>b</math> compleix que <math>(a\cdot b)\in\mathbb{R}.</math>
:b) Té la propietat '''associativa''', és a dir que:
::Per a qualsevol <math>a,\; b</math> i <math>c</math> compleix que <math>(a\cdot b)\cdot c=a\cdot(b\cdot c).</math>
::'''Notació''': escriurem simplement <math>\;a\cdot b\cdot c\;</math> 𝓸 <math>\;a\; b\; c.</math>
:c) Té la propietat '''commutativa''', és a dir que:
::Per a qualsevol <math>a</math> i <math>b</math> compleix que <math>a\cdot b=b\cdot a.</math>
:d) Té un únic element '''neutre''' <math>u\in\mathbb{R}</math> per a la multiplicació, és a dir:
::Per a qualsevol <math>a</math> compleix que <math>a\cdot u=a.</math>
::'''Notació''': es diu unitat i s'escriu com <math>u=1.</math>
:e) Cada element, diferent de zero, té un únic element '''invers''' per la multiplicació, és a dir:
::Per a qualsevol <math>a</math> compleix que existeix un únic <math>b\in\mathbb{R}</math> tal que <math>a\cdot b=1.</math>
::'''Notació''': es diu invers multiplicatiu i s'escriu com <math>b=a^{-1}=\frac{1}{a}.</math>
::'''Notació''': es pot escriure <math>a\cdot c^{-1}=a\cdot\frac{1}{c}=\frac{a}{c}.</math>
3) Té la propietat '''distributiva''' respecte la suma on donats <math>a,b,c\in\mathbb{R}</math> llavors:
:Es compleix que <math>a\cdot (b+c)=a\cdot b+a\cdot c.</math>
4) Té una relació d'ordre, <math>\;\le\;</math>, on donats <math>a,b,c\in\mathbb{R}</math> llavors:
:a) Té una relació d'ordre '''total''', és a dir, sempre <math>\;a\le b\;</math> 𝓸 <math>\;b\le a.</math>
:b) Té la propietat '''reflexiva''', és a dir, sempre podem afirmar que <math>a\le a.</math>
:c) Té la propietat '''antisimètrica''', és a dir, si <math>\;a\le b\;</math> i <math>\;b\le a\;</math> es compleix que <math>a=b.</math>
:d) Té la propietat '''transitiva''', és a dir, si <math>\;a\le b\;</math> i <math>\;b\le c\;</math> es compleix que <math>\;a\le c.</math>
5) La relació d'ordre és compatible amb les operacions on donats <math>a,b,c\in\mathbb{R}</math> llavors:
:a) Si <math>\;a\le b\;</math> compleix que <math>\;a+c\le b+c.</math>
:b) Si <math>\;0\le a\;</math> i <math>\;0\le b\;</math> compleix que <math>\;0\le a\cdot b.</math>
==== Exercicis ====
1) Troba la <math>x</math> en cada cas i comprova que és correcte efectuant la operació sense calculadora:
{|
|width="5px"|
|width="200px"|a) <math>\tfrac{2}{5}+ x=0</math>
|width="200px"|b) <math>\tfrac{7}{3}- x=1</math>
|width="200px"|c) <math>3\cdot x=1</math>
|width="200px"|d) <math>x\cdot\tfrac{2}{5}=1</math>
|-
|||e) <math>x\cdot\tfrac{3}{2}=0</math>
|f) <math>\tfrac{5}{x}=1</math>
|g) <math>\frac{x}{\;\tfrac{5}{3}\;}=1</math>
|h) <math>\frac{\;\tfrac{2}{9}\;}{\tfrac{2}{9}}=x</math>
|-
|||i) <math>\tfrac{3}{5}\le x</math>
|j) <math>\tfrac{x}{3}+\pi\le \tfrac{4}{3}+\pi</math>
|k) <math>x\le\tfrac{2}{7}</math> i <math>\tfrac{2}{7}\le x</math>
|l) <math>\tfrac{6}{9}\le x</math> i <math>x\le \tfrac{8}{9}</math>
|}
=== Potències ===
{|class="floatright" width="149px" style="border: 1px solid #08f"
|style="border: 1px solid #08f"|<math>a\cdot\frac{b}{c}=\frac{b}{c}\cdot a=\frac{a\;b}{c}</math>
|-
|style="border: 1px solid #08f"|<math>\frac{a}{b}\cdot\frac{c}{d}=\frac{a\cdot c}{b\cdot d}</math>
|-
|style="border: 1px solid #08f"|<math>\frac{a\cdot c}{c\cdot d}=\frac{a\cdot \color{red}{\cancel c}}{\color{red}{\cancel c} \color{black}\cdot d}=\frac{a}{d}</math>
|-
|style="border: 1px solid #08f"|<math>\frac{a}{b}\div\frac{c}{d}=\frac{a}{b}\cdot\frac{d}{c}</math>
|}
'''Definició:''' Una '''potència''' amb base <math>a\in\mathbb{R}</math> i exponent un nombres natural, es defineix recursivament amb:
<math>\begin{array}{|c l|}
\hline
a^1 =& a \\
\color{grey} a^2 =& \color{grey} a\cdot a \\
\color{grey} a^3 =& \color{grey} a^2\cdot a= a\,\cdot\,a\,\cdot\,a\\
\vdots & \\
\color{grey} a^n =& \color{grey} \underbrace{a\,\cdot\, ...\,\cdot\, a}_{n\; vegades} \\
a^{n+1}=& a^n\;\cdot\;a\\
\vdots & \\
\hline
\end{array}</math>
La part gris és innecessària, és per millorar la comprensió. Amb aquesta definició queda determinada totes les potències amb exponent un nombre natural positiu a partir del primer terme <math>a,</math> ja que cada nova potència es pot posar com conseqüència de la anterior i aquest fet s'en diu definició recursiva.
==== Propietats ====
{|style="border: 1px solid #00f;" cellpadding="3" cellspacing="0" width="368px" bgcolor="#f9f9ff"
|-
|style="border: 1px solid #00f;" width="120px"|<math>a^n \cdot a^m=a^{n+m}</math>
|style="border: 1px solid #00f;" width="220px"|<math>\left(a^n \right)^m=a^{n \cdot m}</math>
|-
|style="border: 1px solid #00f;" width="120px"|<math>\left(a \cdot b \right)^n=a^n \cdot b^n</math>
|style="border: 1px solid #00f;" width="220px"|<math>(-a)^n=\begin{cases} a^n & \text{ si n parell } \\
-a^n & \text{ si n imparell } \end{cases}</math>
|}
'''Notació''' per a exponents amb valors enters i base diferent de zero:
<math>\begin{array}{|c l|}
\hline
a^{-1}= & \frac{1}{a} \\
\hline
\end{array}\;</math> on <math>\;a\neq 0</math>
i inductivament la notació és <math>a^{-(n+1)}=a^{-n}\cdot \frac{1}{a}</math>
;Propietats:
{|style="border: 1px solid #00f;" cellpadding="3" cellspacing="0" bgcolor="#f9f9ff" width="272px"
|-
|style="border: 1px solid #00f;" width="95px"|
<math>a^{-n}=\frac{1}{a^n}</math>
|style="border: 1px solid #00f;" width="160px"|
<math>a^n=\frac{1}{a^{-n}}</math>
|-
|style="border: 1px solid #00f;" width="95px"|
<math>\left(\frac{a}{b}\right)^n=\frac{a^n}{b^n}</math>
|style="border: 1px solid #00f;" width="160px"|
<math>\frac{a^n}{a^m}=a^{n-m}=\frac{1}{a^{m-n}}</math>
|-
|style="border: 1px solid #00f;" colspan="2"|
<math>a^0=1\,\,\text{només si}\,\,a\neq 0</math>
|}
==== Exemples ====
1) Simplifica i expressa com a una sola potència, és a dir que la solució sigui de la forma <math>\Big(\;\;...\;\;\Big)^s:</math>
{|cellspacing="0" cellpadding="0" style="border: 1px solid #77d; background:#f8f8ff;width:100%"
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució i test" data-collapsetext="Ocultar"
|-
|a) <math>\frac{ (a^6)^2\cdot \left( \frac{a^3}{a^5}\right)^3 }{ b^{11}\cdot b^{-5} }\;=</math>
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Es seleccionen elements que es poden agrupar com:
:<math>\;(a^6)^2=a^{6\cdot 2}=a^{12}\;\;,</math> <math>\;\;\frac{a^3}{a^5}=a^{3-5}=a^{-2}\;\;</math> i <math>\;\;b^{11}\cdot b^{-5}=b^{11-5}=b^6</math>
L'expressió inicial queda simplificada com <math>\frac{ a^{12}\;\cdot \;(\;a^{-2}\;)^3 }{ b^6 }</math>
Agrupem tot el numerador <math>a^{12}\cdot (a^{-2})^3 =a^{12+(-2)\cdot 3}=a^6\;:</math>
L'expressió inicial queda ara com <math>\frac{ a^6 }{ b^6 }</math> i agrupant potències queda <math>\left(\;\frac{a}{b}\;\right)^6</math>
Per tant queda com a una sola potència.
'''Test'''
La resolució té estructura de prova, llavors en comptes d'una prova es farà un '''sondeig''' amb nombres primers, com <math>a=3</math> i el <math>b=5,</math> i a cop de calculadora es fa el sondeig:
:<math>\frac{ (3^6)^2\cdot \left( \frac{3^3}{3^5}\right)^3 }{ 5^{11}\cdot 5^{-5} }=\frac{ 729^2\cdot \left( \frac{27}{243}\right)^3 }{ 15\;625 }=\frac{729}{15\;625}=\left(\frac{3}{5}\right)^6</math>
S'ha fet així almenys un sondeig.
|}
|-
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució i test" data-collapsetext="Ocultar"
|b) <math>\frac{ a^6\cdot b^6 }{ (a\cdot b)^6 +\left(\frac{a^3}{b^2}\frac{b^3}{a^2} \right)^6 }\;=</math>
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Es seleccionen elements que es poden agrupar com:
:<math>a^6\cdot b^6=(a\cdot b)^6\;</math> i <math>\;\frac{a^3}{b^2}\frac{b^3}{a^2}=\frac{a^3\;b^3}{b^2\;a^2}=a^{3-2}\;b^{3-2}=a\cdot b</math>
L'expressió inicial queda tot de cop com <math>\frac{ (a\cdot b)^6 }{ (a\cdot b)^6 +(a\cdot b)^6 }=</math> <math>\frac{ (a\cdot b)^6 }{2 (a\cdot b)^6 }=</math> <math>\frac{ \cancel{(a\cdot b)^6} }{2 \cancel{(a\cdot b)^6} }=</math> <math>\frac{1}{2}</math>
'''Nota:''' és important que <math>\frac{ \cancel{c} }{ \cancel{c} }=\frac{1}{1}=1</math> només es pot fer si <math>c\neq 0.</math>
'''Test'''
S'agafa doncs <math>a=3</math> i <math>b=5</math> per fer '''un''' sondeig a veure que surt:
<math>\frac{ 3^6\cdot 5^6 }{ (3\cdot 5)^6 +\left(\frac{3^3}{5^2}\frac{5^3}{3^2} \right)^6 }=\frac{11\;390\;625}{22\;781\;250}=\frac{1}{2}</math>
S'ha fet així almenys un sondeig.
|}
|}
2) Simplifica i expressa com a una sola fracció, és a dir que la solució sigui de la forma <math>\frac{\Big(\;\;...\;\;\Big)}{\Big(\;\;...\;\;\Big)}:</math>
{|cellspacing="0" cellpadding="0" style="border: 1px solid #77d; background:#f8f8ff;width:100%"
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució" data-collapsetext="Ocultar"
|-
|a) <math>\frac{r\cdot\frac{\;\;\tfrac{r^3}{s^4}\;\;}{r^2} }{ \frac{1}{\;\;\tfrac{r}{s}\;\;} }\;=</math>
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Podem aplicar que parlant de fraccions el elements o bé multipliquen(numerador) o bé divideixen(denominador), afegint que, qui divideix al que divideix llavors passa a multiplicar al numerador, <math>\frac{1}{\;\;\frac{a}{b}\;\;}=\frac{b}{a},</math> i qui divideix una fracció passa a multiplicar al denominador, <math>\frac{\;\;\frac{1}{a}\;\;}{b}=\frac{1}{a\cdot b}.</math>
Una altra alternativa és utilitzar la fórmula <math>\frac{\;\;\frac{a}{b}\;\;}{\frac{c}{d}}=\frac{a\;d}{b\;c}</math> segament.
Es seleccionen elements que es poden agrupar com:
:<math>\frac{\;\;\tfrac{r^3}{s^4}\;\;}{r^2}=\color{grey}\frac{\;\;\tfrac{r^3}{s^4}\;\;}{\frac{\;\;r^2\;\;}{1}}\color{black}=\frac{r^3\; 1}{s^4\; r^2}=\frac{r^{3-2}}{s^4}=\frac{r}{s^4}</math>
:<math>\frac{1}{\;\;\tfrac{r}{s}\;\;}=\color{grey}\frac{\tfrac{1}{1}}{\;\;\tfrac{r}{s}\;\;}\color{black}=\frac{s\; 1}{r\; 1}=\frac{s}{r}</math>
Llavors l'expressió inicial queda simplificada i es pot reduir més <math>\frac{r\cdot\frac{r}{s^4} }{ \frac{s}{r} }=\frac{r^2\;r}{s^4\;s}=\frac{r^{2+1}}{s^{4+1}}=\frac{r^3}{s^5}.</math>
|}
|}
3) Simplifica al màxim:
{|cellspacing="0" cellpadding="0" style="border: 1px solid #77d; background:#f8f8ff;width:100%"
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució" data-collapsetext="Ocultar"
|-
|a) <math>\frac{x^2 \;10^{10}\; y^4\;9^{10} }{ 6^{9}\; x^7\; y^2\; 15^{11} }\;=</math>
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Primer de tot factoritzem les bases de cada potència per veure quins valors es poden simplificar i desprès agrupen elements amb mateixa base:
Al numerador hi ha <math>10^{10}=(2\cdot 5)^{10}=2^{10}\;5^{10}\;</math> i <math>\;9^{10}=(3\cdot 3)^{10}=3^{10}\;3^{10}=3^{10+10}=3^{20}</math>
Al denominador hi ha <math>6^{9}=(2\cdot 3)^{9}=2^{9}\;3^{9}\;</math> i <math>\;15^{11}=(3\cdot 5)^{11}=3^{11}\;5^{11}</math>
Llavors a l'expressió inicial queda agrupar exponents de forma que siguin positius:
:<math>\frac{x^2 \;2^{10}\;5^{10}\; y^4\;3^{20} }{ 2^{9}\;3^{9}\; x^7\; y^2\; 3^{11}\;5^{11} }\;</math> <math>=\;\frac{ 2^{10-9}\;y^{4-2}\;3^{20-9-11} }{ x^{7-2}\;5^{11-10} }</math> <math>=\;\frac{2\;y^2}{x^5\;5}.</math>
|}
|}
==== Exercicis ====
1) Simplifica i expressa coma a una sola potència:
{|
|width="5px"|
|width="230px"|a) <math>(2\;a)^5\left(\frac{2^3}{2^4 a}\right)^2</math>
|width="230px"|b) <math>\left(\frac{(a^5 3)^2}{(3^5 a)^2}\right)^3</math>
|width="400px"|c) <math>\frac{a^{15}+b^{20}+(-b)^{20}+(-a)^{15}}{2\;a^{10}\;b^{10}}</math>
|}
2) Simplifica i expressa com a una sola fracció:
{|
|width="5px"|
|width="230px"|a) <math>a^6\, b^{-3}\, 5^{10}\,15^{-5}</math>
|width="230px"|b) <math>\frac{\;\;\frac{(-2^2)^3\,a^4}{(b^2)^5}\;\;}{\frac{2^8}{a^4}\,\frac{b^4}{(a^{-1})^{3}} }</math>
|width="240px"|c) <math>\left(\tfrac{3}{2}\right)^5\left(\tfrac{3}{5}\right)^{-6}\left(\tfrac{7}{2}\right)^{-4}</math>
|}
=== Arrels ===
Les arrels també són potències, de fet neixen en resoldre equacions del tipus <math>x^n=a</math> on <math>x</math> és la incògnita.
'''Definició''': L'arrel n-èsima de a, <math>\sqrt[n]{a},</math> és un valor real <math>r</math> i implica o compleix que <math>r^n=a</math> amb <math>2\le n.</math><ref>Es pot escriure com <math>\sqrt[n]{a}=r\;\Rightarrow\;r^n=a</math> però compta amb la implicació <math>r^n=a\;\Rightarrow\;\sqrt[n]{a}=r</math> perquè afirma que l'arrel genera aquest valor exclusivament i no és així, per exemple:
:És correcte la implicació <math>\sqrt{4}=2\;\Rightarrow\;2^2=4</math>
:És falsa la implicació <math>(-2)^2=4\;\Rightarrow\;\sqrt{4}=-2</math>
L'arrel quadrada és una funció i mai pot dir que <math>\sqrt{4}=\pm\;2,</math> això només ho poden fer les equacions del tipus <math>x^2=4</math> que sí generen dos solucions <math>x_1=2\;,\;x_2=-2.</math>
No feu cas de <math>\sqrt[n]{a}=r\;\Leftrightarrow\;r^n=a</math> molt abundant.</ref>
'''Notació''': <math>\sqrt[n]{a}\;=\;a^{\frac{1}{n}}</math>
'''Exemple''':
Donada l'equació <math>x^5=3,</math> si, per hipòtesi, '''una''' solució és una potència com <math>3^n</math> llavors en substituir-lo a l'equació queda <math>(3^n)^5=3</math> <math>\Rightarrow 3^{n\cdot 5}=3^1</math> i és cert quan <math>n\cdot 5=1</math> és a dir <math>n=\tfrac{1}{5}</math> llavors la solució és <math>3^n=3^{\tfrac{1}{5}}=\sqrt[5]{3}.</math>
==== Propietats ====
1) No sempre hi ha arrels:
{|cellspacing="0" cellpadding="4" style="border: 1px solid #88e; background:#fff"
|style="border: 1px solid #88e; background:#ace" colspan="3" align="center"|<math>\sqrt[n]{\;a\;}=r</math>
|-
|style="border: 1px solid #88e;"|
|style="border: 1px solid #88e;"|n parell
|style="border: 1px solid #88e;"|n imparell
|-
|style="border: 1px solid #88e;"|<math>a<0</math>
|style="border: 1px solid #88e; background:#fa8"|No existeix <math>r</math>
|style="border: 1px solid #88e;"|Existeix <math>r<0</math>
|-
|style="border: 1px solid #88e;"|<math>a\ge 0</math>
|style="border: 1px solid #88e;"|Existeix <math>r\ge 0</math>
|style="border: 1px solid #88e;"|Existeix <math>r\ge 0</math>
|}
'''Nota''': Si <math>-b<0</math> i '''n''' imparell podem reescriure l'arrel <math>\sqrt[n]{\;-b\;}=-\sqrt[n]{\;b\;}</math>
2) Queda definit que <math>\sqrt[n]{\;a\;}^{\;m} =\left(a^{\tfrac{1}{n}}\right)^m=a^{\frac{m}{n}}</math> on <math>\frac{m}{n}</math> es pot reduir tant com es vulgui però la restricció anterior estarà vigent per l'inicial '''n''' parell independentment de es si simplifica amb '''m'''.
3) No sempre es pot equiparar la notació ja que '''m''' parell dins l'arrel es carrega el signe.
{|cellspacing="0" cellpadding="4" style="border: 1px solid #88e; background:#fff"
|style="border: 1px solid #88e; background:#ace" colspan="3" align="center"|<math>\sqrt[n]{a^{\phantom{1} m}}=</math>
|-
|style="border: 1px solid #88e;"|
|style="border: 1px solid #88e;"|n parell
|style="border: 1px solid #88e;"|n imparell
|-
|style="border: 1px solid #88e;"|m parell
|style="border: 1px solid #88e;" align="center"|<math>|a|^{\tfrac{m}{n}}</math>
|style="border: 1px solid #88e;" align="center"|<math>|a|^{\tfrac{m}{n}}</math>
|-
|style="border: 1px solid #88e;"|m imparell
|style="border: 1px solid #88e;" align="center"|<math>a^{\tfrac{m}{n}}{}_{a\ge 0}</math>
|style="border: 1px solid #88e;" align="center"|<math>a^{\tfrac{m}{n}}</math>
|}
==== Exemples ====
1) Determina el valor de cada arrel comprovant que sigui correcta:
{|cellspacing="0" cellpadding="0" style="border: 1px solid #77d; background:#f8f8ff;width:100%"
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució i prova" data-collapsetext="Ocultar"
|-
|a) <math>\sqrt[6]{\;64\;}=2</math>
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Com que <math>64>0</math> llavors es pot fer el càlcul
:<math>\sqrt[6]{\;64\;}=\sqrt[6]{\;2^6\;}=2^{\tfrac{6}{6}}=2.</math>
'''Prova'''
El requeriment de la definició és que <math>2^6=64</math> i confirma el càlcul.
|}
|-
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució i prova" data-collapsetext="Ocultar"
|-
|b) <math>\sqrt[3]{\;-125\;}=-5</math>
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Com que tres és imparell llavors l'arrel existeix i dona negativa.
:<math>\sqrt[3]{\;-125\;}=-\sqrt[3]{\;125\;}=-\sqrt[3]{\;5^3\;}=-5^{\tfrac{3}{3}}=-5.</math>
'''Prova'''
El requeriment de la definició és que <math>(-5)^3=(-5)(-5)(-5)=-125</math> i confirma el càlcul.
|}
|-
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució i prova" data-collapsetext="Ocultar"
|-
|c) <math>\sqrt[4]{\;-32\;}</math> no existeix.
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Com que quatre és parell i <math>-32<0</math> llavors l'arrel no existeix.
No fa falta prova.
|}
|-
|style="border: 1px solid #77d;width:50%" valign="top"|
{|cellspacing="3" cellpadding="3" style="border: 0px solid #77d; background:#f8f8ff;width:100%;height:100%" class="mw-collapsible mw-collapsed" data-expandtext="Resolució i prova" data-collapsetext="Ocultar"
|-
|d) <math>\sqrt[8]{(-3)^8}=3</math>
|-
|style="border: 1px solid #bbf;background:#fff"|'''Resolució'''
Com que l'index de la arrel és vuit que és parell i <math>(-3)^8>0</math> llavors l'arrel existeix i dona positiu.
:<math>\sqrt[8]{(-3)^8}=\sqrt[8]{(3)^8}=3^{\tfrac{8}{8}}=3^1=3.</math>
'''Prova'''
El requeriment de la definició és que <math>(-3)^8=(3)^8</math> i confirma el càlcul.
|}
|}
==== Exercicis ====
1) Confirma que existeix i calcula:
{|
|width="5px"|
|width="180px"|a) <math>\sqrt[4]{\;2^{\;8}\;}</math>
|width="180px"|b) <math>\sqrt[8]{\,(-4)^4\;}</math>
|width="180px"|c) <math>\sqrt[6]{-3\;}^{\;2}</math>
|width="180px"|d) <math>\sqrt[3]{-1\;000\;000}</math>
|-
|||e) <math>\sqrt[6]{\;6^{12}\;}</math>
|f) <math>\sqrt[172]{-1^2}</math>
|g) <math>\sqrt[30]{0^7}</math>
|h) <math>\sqrt[2]{-1}^{\;20}</math>
|}
== Notes ==
[[Category:Matemàtiques de batxillerat]]
[[Category:CA]]
9ad3mw2naxyxxvvugahxmgyl5fkf5ke
Template:Matematika
10
56031
385918
2026-08-05T08:13:15Z
OwlyKnight
53456
Disalin dari [[:w:id:Templat:Math]]
385918
wikitext
text/x-wiki
<span class="texhtml {{#if:{{{big|}}}{{{size|}}}|texhtml-big}}" {{#if:{{{big|}}}{{{size|}}}|style="font-size:{{{size|165%}}};"}}>{{{1}}}</span>
eplecqpqm3cdskv4q7wh9u0x1jdwspr
385919
385918
2026-08-05T08:13:38Z
OwlyKnight
53456
385919
wikitext
text/x-wiki
<span class="texhtml {{#if:{{{big|}}}{{{size|}}}|texhtml-big}}" {{#if:{{{big|}}}{{{size|}}}|style="font-size:{{{size|165%}}};"}}>{{{1}}}</span><noinclude>[[Category:ID]]</noinclude>
6flnp41zzng4sd4z8i2cs12caw9dlna
385920
385919
2026-08-05T08:14:33Z
OwlyKnight
53456
385920
wikitext
text/x-wiki
<span class="texhtml {{#if:{{{big|}}}{{{size|}}}|texhtml-big}}" {{#if:{{{big|}}}{{{size|}}}|style="font-size:{{{size|165%}}};"}}>{{{1}}}</span><noinclude>[[Category:ID]] [[Category:Templat format matematika]]</noinclude>
0m5jb8wp17ljlltw8yg88pfp6ojzovc
Category:Templat format matematika
14
56032
385921
2026-08-05T08:14:46Z
OwlyKnight
53456
Created page with "[[Category:ID]]"
385921
wikitext
text/x-wiki
[[Category:ID]]
5in2hhs69t17soj3elwwuivu08p4czq
Template:Pecahan
10
56033
385922
2026-08-05T08:22:54Z
OwlyKnight
53456
Disalin dari [[:w:id:Templat:Sfrac]]
385922
wikitext
text/x-wiki
{{ {{{|safesubst:}}}#invoke:Unsubst||$B=<span class="sfrac nowrap"{{#if:{{{3|}}}|>{{{1}}}<span class="visualhide"> </span><span}} <!--
-->style="display:inline-block; vertical-align:-0.5em; font-size:85%; text-align:center;"><!--
--><span style="display:block; line-height:1em; margin:0 0.1em;">{{#if:{{{3|}}}|{{{2}}}|{{#if:{{{2|}}}|{{{1}}}|1}}}}</span><!--
--><span style="display:block; line-height:1em; margin:0 0.1em; border-top:1px solid;">{{{3|{{{2|{{{1}}}}}}}}}</span><!--
-->{{#if:{{{3|}}}|</span>}}<!--
--></span>}}<noinclude>
{{documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}}
<!-- PLEASE ADD CATEGORIES TO /doc SUBPAGE - NOT HERE.-->
</noinclude>
ik4b2f3jnuqzd233nfz2xz1ychcza0t
Template:Subskrip
10
56034
385923
2026-08-05T08:26:10Z
OwlyKnight
53456
Created page with "<sub>{{{1}}}</sub><noinclude> {{documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}} </noinclude>"
385923
wikitext
text/x-wiki
<sub>{{{1}}}</sub><noinclude>
{{documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}}
</noinclude>
cj2waciy6ld2s19ubpnm199avam5y4d
Template:Superskrip
10
56035
385924
2026-08-05T08:27:48Z
OwlyKnight
53456
Created page with "<sup>{{{1}}}</sup><noinclude> {{documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}} </noinclude>"
385924
wikitext
text/x-wiki
<sup>{{{1}}}</sup><noinclude>
{{documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}}
</noinclude>
6rfh8k9rbi5ri3rh0a7yd6yowxmsjh2
Template:Subsup
10
56036
385925
2026-08-05T08:37:50Z
OwlyKnight
53456
Disalin dari [[:w:id:Templat:su]]
385925
wikitext
text/x-wiki
<includeonly>{{#if:{{{p|{{{1|}}}}}}|{{#if:{{{b|{{{2|}}}}}}|<span style="{{#ifeq: {{{w|}}}|f| font: 80% monospace; |font-size:80%; }} display:-moz-inline-box; -moz-box-orient:vertical; display:inline-block; vertical-align: bottom; /*Horizontal positioning, affects IE&FF*/margin-bottom:-0.4em; min-height:1em; line-height:1em; {{#switch: {{{a|}}}|r=text-align:right|c=text-align:center}}"><span style="display:block; min-height:1em; /*Horizontal positioning, affects IE only*/margin-top:-1.4em;">{{{p|{{{1| }}}}}}</span><span style="display:block; min-height:1em;">{{{b|{{{2| }}}}}}</span></span>
|{{sup|{{{p|{{{1}}}}}}}}|{{sub|{{{b|{{{2}}}}}}}}}}}}</includeonly><noinclude>
{{documentation}}
</noinclude>
k44846zwq9oy2n21bw4uum67md32mfb
Template:Subsup/doc
10
56037
385926
2026-08-05T08:38:04Z
OwlyKnight
53456
Created page with "Untuk menambahkan subskrip dan superskrip secara bersamaan. Misalnya: <syntaxhighlight lang="wikitext"> {{subsup|239|94}}Pu </syntaxhighlight> akan menghasilkan {{subsup|239|94}}Pu Bisa juga menggunakan <code><nowiki>|p=</nowiki></code> untuk superskrip dan <code><nowiki>|b=</nowiki></code> untuk subskrip. Misalnya: <syntaxhighlight lang="wikitext"> {{subsup|p=239|b=94}}Pu </syntaxhighlight> akan menghasilkan {{subsup|p=239|b=94}}Pu [[Category:ID]] Category:Tem..."
385926
wikitext
text/x-wiki
Untuk menambahkan subskrip dan superskrip secara bersamaan. Misalnya:
<syntaxhighlight lang="wikitext">
{{subsup|239|94}}Pu
</syntaxhighlight>
akan menghasilkan
{{subsup|239|94}}Pu
Bisa juga menggunakan <code><nowiki>|p=</nowiki></code> untuk superskrip dan <code><nowiki>|b=</nowiki></code> untuk subskrip. Misalnya:
<syntaxhighlight lang="wikitext">
{{subsup|p=239|b=94}}Pu
</syntaxhighlight>
akan menghasilkan
{{subsup|p=239|b=94}}Pu
[[Category:ID]]
[[Category:Templat format matematika]]
nyfewd1phurhn23fjkb6h8ly5k979st
Template:Mvar
10
56038
385927
2026-08-05T08:40:39Z
OwlyKnight
53456
Disalin dari [[:w:id:Templat:Mvar]]
385927
wikitext
text/x-wiki
<span class="texhtml mvar" style="font-style:italic;">{{{1}}}</span><noinclude>
{{Documentation|content=Variabel matematika. [[Category:ID]] [[Category:Templat format matematika]]}}
</noinclude>
l13e03fpikh6bbz6gpu7w04mml0emch
Template:Garis atas
10
56039
385928
2026-08-05T08:43:23Z
OwlyKnight
53456
Disalin dari [[:w:id:Templat:Overline]]
385928
wikitext
text/x-wiki
{{#if:{{{2|}}}|{{{1|}}}}}<span style="text-decoration:overline;">{{#if:{{{2|}}}|{{{2}}}|{{{1}}}}}</span><noinclude>
{{Documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}}</noinclude>
ohei8nzmr663viknosufz3dragu2ks0
Template:Set atas
10
56040
385929
2026-08-05T08:44:25Z
OwlyKnight
53456
Disalin dari [[:w:id:Templat:Overset]]
385929
wikitext
text/x-wiki
<includeonly><span class="sfrac nowrap; "><span style="display:none; display:inline-block; text-align:center;"><span style="display:block; line-height:0.8em; font-size:70%; padding:0 0.1em;">{{{1}}}</span><span style="display:block; line-height:1em; padding:0 0.1em;">{{{2}}}</span></span></span></includeonly><noinclude>{{doc}}</noinclude>
qafuvybsnunhbe8osuslq2q1qb5n22d
385930
385929
2026-08-05T08:45:16Z
OwlyKnight
53456
385930
wikitext
text/x-wiki
<includeonly><span class="sfrac nowrap; "><span style="display:none; display:inline-block; text-align:center;"><span style="display:block; line-height:0.8em; font-size:70%; padding:0 0.1em;">{{{1}}}</span><span style="display:block; line-height:1em; padding:0 0.1em;">{{{2}}}</span></span></span></includeonly><noinclude>{{Documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}}</noinclude>
flcm70wrn1mlyb19pbd8b8uv4uchmqm
Template:Set bawah
10
56041
385931
2026-08-05T08:47:06Z
OwlyKnight
53456
Disalin dari [[:w:id:Templat:Underset]]
385931
wikitext
text/x-wiki
<span class="sfrac nowrap"><span style="display:none;display:inline-block; vertical-align:top; text-align:center;"><span style="display:block;{{#if:{{{nopadding|}}}||padding:0 0.1em;}}">{{{2}}}</span><span style="display:block; font-size:70%; line-height:1em;{{#if:{{{nopadding|}}}||padding:0 0.1em;}}"><span style="position:relative; line-height:1em; margin-top:-0.5em; top:-0.5em;">{{{1}}}</span></span></span></span><noinclude>{{documentation|content=[[Category:ID]] [[Category:Templat format matematika]]}}<!---ADD CATEGORIES TO THE \doc PAGE - NOT HERE - THANKS ---></noinclude>
spk94nutc3x1e7s74mzwozj1wrxwet3