From 3e9574d64426b65e561a3ec546ae42dc931166fa Mon Sep 17 00:00:00 2001 From: Reza Sadid Date: Tue, 26 Mar 2024 16:18:25 +0330 Subject: [PATCH] Initial upload of Numerical Analysis Tools project files --- README.md | 64 +++- index.php | 33 ++ method-bisection.php | 173 ++++++++++ method-false-position.php | 173 ++++++++++ method-fixed-point-iteration.php | 183 ++++++++++ method-jacobi.php | 211 ++++++++++++ method-newton-raphson.php | 178 ++++++++++ method-secant.php | 173 ++++++++++ method-simpson.php | 181 ++++++++++ method-trapezoid.php | 174 ++++++++++ numerical-analysis.css | 573 +++++++++++++++++++++++++++++++ numerical-analysis.js | 134 ++++++++ 12 files changed, 2248 insertions(+), 2 deletions(-) create mode 100644 index.php create mode 100644 method-bisection.php create mode 100644 method-false-position.php create mode 100644 method-fixed-point-iteration.php create mode 100644 method-jacobi.php create mode 100644 method-newton-raphson.php create mode 100644 method-secant.php create mode 100644 method-simpson.php create mode 100644 method-trapezoid.php create mode 100644 numerical-analysis.css create mode 100644 numerical-analysis.js diff --git a/README.md b/README.md index c0c06b8..c5286a9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,62 @@ -# numerical-analysis-tools -Explore numerical methods implemented in PHP for solving equations and integrals. Enhance your understanding of numerical analysis techniques. +
+ +

Numerical Analysis Tools

+

+ Explore practical implementations of numerical analysis methods in PHP +

+ View Demo + · + Report an Issue or Request a Feature + · + Collaborate +
+ +
+ +## About The Project + +This repository contains implementations of various numerical analysis methods in PHP. Explore a collection of algorithms for solving equations, finding roots, and integrating functions. Whether you're a student or a professional, these tools provide insights into numerical analysis techniques. + +![Cover Image](https://rezasadid.com/projects/numericalanalysis/cover.jpg) + +### Features + +* Implementation of popular numerical analysis methods +* Detailed documentation and explanations +* Code examples for practical usage +* Easy-to-understand PHP implementations + +### Built With + +Flasher is built using a combination of frontend and backend technologies: + +* Frontend: HTML, CSS +* Backend: PHP + +## Logs + +### Version 1.0 (Initial Release) + +* Uploaded the first version of the repository + +## Contributing + +Contributions are pivotal to the growth of our project. Your input fuels innovation and enhances the user experience for everyone. Whether it's a bug fix, feature suggestion, or enhancement, your efforts are highly valued. Feel free to fork the repository, create a new branch, and share your ideas. If you have any suggestions to improve the project, don't hesitate to open an issue and tag it as "enhancement". Your contributions will be warmly welcomed, and together, we can make this project even better. Thank you for your support! + +1. Fork the Project +2. Create your Feature Branch (`git checkout -b feature/YourFeature`) +3. Commit your Changes (`git commit -m 'Add some YourFeature'`) +4. Push to the Branch (`git push origin feature/YourFeature`) +5. Open a Pull Request + + +## License + +This project is licensed under the MIT License. See the `LICENSE` file for details. + + +## Contact + +For any inquiries or support, feel free to contact: +* Email: contact@rezasadid.com, rezasadid753@gmail.com +* Phone: +98 21 9130 2492 \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..20329ae --- /dev/null +++ b/index.php @@ -0,0 +1,33 @@ + + + + + + + + + +
+

فهرست

+

ریشه یابی

+ روش دوبخشی + روش نابجایی + روش تکرار ساده + روش نیوتون + روش وتری +

حل دستگاه معادلات خطی

+ روش ژاکوبی +

انتگرال گیری عددی

+ روش ذوزنقه ای مرکب + روش سیمپسون +
+
+
+ background
+
+
+ محاسبات عددی +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-bisection.php b/method-bisection.php new file mode 100644 index 0000000..c4bdbab --- /dev/null +++ b/method-bisection.php @@ -0,0 +1,173 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

ریشه یابی - روش دوبخشی

+

+ با وارد کردن تابع مورد نظر در فرم زیر، یکی از ریشه‌های آن در دامنه تعیین‌شده با استفاده از روش دوبخشی محاسبه می‌شود. تکرارها تا زمانی که 7 رقم بامعنا پاسخ ثابت بماند ادامه می‌یابد و در نهایت ریشه تابع با تقریب بدست می‌آید. در صورت تمایل می‌توانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + +
+
+ + +
+
+ + +
+ +
+

یا

+ +
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function = $_POST["function"]; + $a = $_POST["a"]; + $b = $_POST["b"]; + echo 'دامنه مدنظر: ' . $a . ' تا ' . $b . '
'; + echo 'تابع وارد شده: ' . $function . '
'; + $function = str_replace(' ', '', $function); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if ($prechar == 'x' || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if ($prechar !== 'x' && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if ($char == 'x' && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function = convert($function); + $function = str_replace('x', '$x', $function); + echo 'تابع ترجمه شده: ' . $function . ''; + function f($x) + { + global $function; + return eval("return $function;"); + } + $m = 0; + $prec = null; + $stop = false; + while ($m < 100) { + $c = ($a + $b) / 2; + echo '
تکرار شماره ' . $m . 'a=' . $a . ', b=' . $b . ', c=' . $c . ', f(a)=' . f($a) . ', f(c)=' . f($c) . ''; + if (f($a) * f($c) < 0) { + $b = $c; + } elseif (f($a) * f($c) > 0) { + $a = $c; + } else { + echo 'ریشه بصورت دقیق در x = ' . $c . 'پیدا شده است'; + break; + } + echo 'پاسخ محاسبه شده: ' . $c; + if ($prec !== null) { + $delta = abs($c - $prec) / abs($c); + if ($delta < pow(10, -7)) { + $stop = true; + } + } + if ($stop) { + break; + } + $m++; + $prec = $c; + } + } + ?> +
+
+
+
+ background
+
+
+ ریشه یابی - روش دوبخشی +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-false-position.php b/method-false-position.php new file mode 100644 index 0000000..58cd3b6 --- /dev/null +++ b/method-false-position.php @@ -0,0 +1,173 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

ریشه یابی - روش نابجایی

+

+ با وارد کردن تابع مورد نظر در فرم زیر، یکی از ریشه‌های آن در دامنه تعیین‌شده با استفاده از روش نابجایی محاسبه می‌شود. تکرارها تا زمانی که 7 رقم بامعنا پاسخ ثابت بماند ادامه می‌یابد و در نهایت ریشه تابع با تقریب بدست می‌آید. در صورت تمایل می‌توانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + +
+
+ + +
+
+ + +
+ +
+

یا

+ +
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function = $_POST["function"]; + $a = $_POST["a"]; + $b = $_POST["b"]; + echo 'دامنه مدنظر: ' . $a . ' تا ' . $b . '
'; + echo 'تابع وارد شده: ' . $function . '
'; + $function = str_replace(' ', '', $function); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if ($prechar == 'x' || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if ($prechar !== 'x' && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if ($char == 'x' && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function = convert($function); + $function = str_replace('x', '$x', $function); + echo 'تابع ترجمه شده: ' . $function . ''; + function f($x) + { + global $function; + return eval("return $function;"); + } + $m = 0; + $prec = null; + $stop = false; + while ($m < 100) { + $c = (($a * f($b)) - ($b * f($a))) / (f($b) - f($a)); + echo '
تکرار شماره ' . $m . 'a=' . $a . ', b=' . $b . ', c=' . $c . ', f(a)=' . f($a) . ', f(c)=' . f($c) . ''; + if (f($a) * f($c) < 0) { + $b = $c; + } elseif (f($a) * f($c) > 0) { + $a = $c; + } else { + echo 'ریشه بصورت دقیق در x = ' . $c . 'پیدا شده است'; + break; + } + echo 'پاسخ محاسبه شده: ' . $c; + if ($prec !== null) { + $delta = abs($c - $prec) / abs($c); + if ($delta < pow(10, -7)) { + $stop = true; + } + } + if ($stop) { + break; + } + $m++; + $prec = $c; + } + } + ?> +
+
+
+
+ background
+
+
+ ریشه یابی - روش نابجایی +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-fixed-point-iteration.php b/method-fixed-point-iteration.php new file mode 100644 index 0000000..5df5b8f --- /dev/null +++ b/method-fixed-point-iteration.php @@ -0,0 +1,183 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

ریشه یابی - روش تکرار ساده

+

+ با وارد کردن تابع مورد نظر در فرم زیر، یکی از ریشه‌های آن در دامنه تعیین‌شده با استفاده از روش تکرار ساده (نقطه ثابت) محاسبه می‌شود. تکرارها تا زمانی که 4 رقم بامعنا g و x باهم برابر باشند و در نهایت ریشه تابع با تقریب بدست می‌آید. در صورت تمایل می‌توانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + + x= +
+
+ + +
+
+ + +
+
+ + +
+ +
+

یا

+ +
+ در تابع پیشفرض، تابع بصورت + (2x+5)*sin(x)+6+100x=100x + بازنویسی شده است که تابع g برابر خواهد بود با + ((2x+5)*sin(x)+6+100x)/100 + و مقدار تخمین اولیه نیز 0 درنظر گرفته شده است +
+
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function = $_POST["function"]; + $a = $_POST["a"]; + $b = $_POST["b"]; + $initial = $_POST["initial"]; + echo 'مقدار تخمین اولیه: ' . $initial . '
'; + echo 'دامنه مدنظر: ' . $a . ' تا ' . $b . '
'; + echo 'تابع وارد شده: x=' . $function . '
'; + $function = str_replace(' ', '', $function); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if ($prechar == 'x' || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if ($prechar !== 'x' && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if ($char == 'x' && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function = convert($function); + $function = str_replace('x', '$x', $function); + echo 'تابع ترجمه شده: g( $x ) = ' . $function . ''; + function f($x) + { + global $function; + return eval("return $function;"); + } + $m = 0; + $stop = false; + while ($m < 100) { + echo '
تکرار شماره ' . $m . 'x=' . $initial . ', g(x)=' . f($initial) . ''; + $difference = abs($initial - f($initial)) / abs($initial) >= pow(10, -4); + if ($initial !== f($initial) && $difference ) { + $initial = f($initial); + } else { + echo 'ریشه بصورت دقیق در x = ' . $initial . 'پیدا شده است'; + break; + } + echo 'پاسخ محاسبه شده: ' . $initial; + if (f($initial) !== null) { + $delta = abs($initial - f($initial)) / abs($initial); + if ($delta < pow(10, -4)) { + $stop = true; + } + } + if ($stop) { + break; + } + $m++; + } + } + ?> +
+
+
+
+ background
+
+
+ ریشه یابی - روش تکرار ساده +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-jacobi.php b/method-jacobi.php new file mode 100644 index 0000000..f702f59 --- /dev/null +++ b/method-jacobi.php @@ -0,0 +1,211 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

انتگرال گیری عددی - روش ژاکوبی

+

+ با وارد کردن سه معادله بر حسب x و y و z با سه مجهول x و y و z در فرم زیر، مجهولات آن با استفاده از روش ژاکوبی با صفر قرار دادن نقاط اولیه برای هر سه متغیر و تکرار تا زمانی که چهار رقم بامعنا هر سه متغیر ثابت بماند محاسبه میشود. در صورت تمایل می‌توانید معادلات دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از معادلات پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + + x= +
+
+ + + y= +
+
+ + + z= +
+ +
+

یا

+ +
+ معادلات به ترتیب بصورت + x=(2-y-z)/7 + و + y=(5-(2x+6z))/15 + و + z=(8-2x+y)/5 + بازنویسی میشوند تا بتوان در رابطه جایگذاری کرد +
+
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function1 = $_POST["function1"]; + $function2 = $_POST["function2"]; + $function3 = $_POST["function3"]; + echo 'معادله اول وارد شده: x=' . $function1 . '
'; + echo 'معادله دوم وارد شده: y=' . $function2 . '
'; + echo 'معادله سوم وارد شده: z=' . $function3 . '
'; + $function1 = str_replace(' ', '', $function1); + $function2 = str_replace(' ', '', $function2); + $function3 = str_replace(' ', '', $function3); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if (($chprecharar == 'x' || $prechar == 'y' || $prechar == 'z') || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if (($prechar !== 'x' || $prechar !== 'y' || $prechar !== 'z') && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if (($char == 'x' || $char == 'y' || $char == 'z') && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function1 = convert($function1); + $function1 = str_replace('x', '$x', $function1); + $function1 = str_replace('y', '$y', $function1); + $function1 = str_replace('z', '$z', $function1); + $function2 = convert($function2); + $function2 = str_replace('x', '$x', $function2); + $function2 = str_replace('y', '$y', $function2); + $function2 = str_replace('z', '$z', $function2); + $function3 = convert($function3); + $function3 = str_replace('x', '$x', $function3); + $function3 = str_replace('y', '$y', $function3); + $function3 = str_replace('z', '$z', $function3); + echo 'معادله ترجمه شده اول: $x = ' . $function1 . '
'; + echo 'معادله ترجمه شده دوم: $y = ' . $function2 . '
'; + echo 'معادله ترجمه شده سوم: $z = ' . $function3 . ''; + function f1($y, $z) + { + global $function1; + return eval("return $function1;"); + } + function f2($x, $z) + { + global $function2; + return eval("return $function2;"); + } + function f3($y, $z) + { + global $function3; + return eval("return $function3;"); + } + $m = 0; + $x = 0; + $y = 0; + $z = 0; + $oldx = 0; + $oldy = 0; + $oldz = 0; + $stop = false; + while ($m < 100) { + echo '
تکرار شماره ' . $m; + $x = f1($y, $z); + $y = f2($x, $z); + $z = f3($y, $z); + echo 'x=' . $x . ', y=' . $y . ', z=' . $z . ''; + $delta1 = abs($x - $oldx) / abs($x); + $delta2 = abs($y - $oldy) / abs($y); + $delta3 = abs($z - $oldz) / abs($z); + if ($delta1 < pow(10, -4) && $delta2 < pow(10, -4) && $delta3 < pow(10, -4)) { + $stop = true; + } + if ($stop) { + break; + } + $oldx = $x; + $oldy = $y; + $oldz = $z; + $m++; + } + } + ?> +
+
+
+
+ background
+
+
+ انتگرال گیری عددی - روش ژاکوبی +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-newton-raphson.php b/method-newton-raphson.php new file mode 100644 index 0000000..11e725e --- /dev/null +++ b/method-newton-raphson.php @@ -0,0 +1,178 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

ریشه یابی - روش نیوتون

+

+ با وارد کردن تابع مورد نظر و مشتق آن در فرم زیر، یکی از ریشه‌های آن با استفاده از روش دوبخشی با توجه به مقدار تخمینی اولیه وارد شده محاسبه میشود. تکرارها تا زمانی که 7 رقم بامعنا پاسخ ثابت بماند ادامه می‌یابد و در نهایت ریشه تابع با تقریب بدست می‌آید. در صورت تمایل می‌توانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + +
+
+ + +
+
+ + +
+ +
+

یا

+ +
+ مشق تابع پیشفرض برابر با + (2*sin(x))+((2*x+5)*cos(x)) + در نظر گرفته شده است +
+
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function = $_POST["function"]; + $functionderivative = $_POST["functionderivative"]; + $initial = $_POST["initial"]; + echo 'تخمین اولیه: ' . $initial . '
'; + echo 'تابع وارد شده: ' . $function . '
'; + echo 'مشتق تابع وارد شده: ' . $functionderivative . '
'; + $function = str_replace(' ', '', $function); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if ($prechar == 'x' || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if ($prechar !== 'x' && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if ($char == 'x' && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function = convert($function); + $function = str_replace('x', '$x', $function); + echo 'تابع ترجمه شده: ' . $function . '
'; + $functionderivative = convert($functionderivative); + $functionderivative = str_replace('x', '$x', $functionderivative); + echo 'مشتق تابع ترجمه شده: ' . $functionderivative . ''; + function f($x) + { + global $function; + return eval("return $function;"); + } + function df($x) + { + global $functionderivative; + return eval("return $functionderivative;"); + } + $m = 0; + $stop = false; + $x = $initial; + while ($m < 100) { + echo '
تکرار شماره ' . $m . 'x=' . $x . ', f(x)=' . f($x) . ', df(x)/dx=' . df($x) . ''; + $oldx = $x; + $x = $x - (f($x) / df($x)); + echo 'پاسخ محاسبه شده: ' . $x; + $delta = abs($x - $oldx) / abs($x); + if ($delta < pow(10, -7)) { + $stop = true; + } + if ($stop) { + break; + } + $oldx = $x; + $m++; + } + } + ?> +
+
+
+
+ background
+
+
+ ریشه یابی - روش نیوتون +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-secant.php b/method-secant.php new file mode 100644 index 0000000..147247c --- /dev/null +++ b/method-secant.php @@ -0,0 +1,173 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

ریشه یابی - روش وتری

+

+ با وارد کردن تابع مورد نظر و دو مقدار اولیه دلخواه، یکی از ریشه‌های آن با استفاده از روش وتری محاسبه میشود. تکرارها تا زمانی که 7 رقم بامعنا پاسخ ثابت بماند ادامه می‌یابد و در نهایت ریشه تابع با تقریب بدست می‌آید. در صورت تمایل می‌توانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + +
+
+ + +
+
+ + +
+ +
+

یا

+ +
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function = $_POST["function"]; + $a = $_POST["a"]; + $b = $_POST["b"]; + echo 'مقادیر اولیه وارد شده: ' . $a . ' و ' . $b . '
'; + echo 'تابع وارد شده: ' . $function . '
'; + $function = str_replace(' ', '', $function); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if ($prechar == 'x' || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if ($prechar !== 'x' && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if ($char == 'x' && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function = convert($function); + $function = str_replace('x', '$x', $function); + echo 'تابع ترجمه شده: ' . $function . ''; + function f($x) + { + global $function; + return eval("return $function;"); + } + $m = 0; + $x = 0; + $stop = false; + while ($m < 100) { + echo '
تکرار شماره ' . $m . 'a=' . $a . ', b=' . $b . ', f(a)=' . f($a) . ', f(b)=' . f($b) . ''; + $oldx = $x; + $x = $a - ((f($a) * ($b - $a)) / (f($b) - f($a))); + if (f($a) * f($x) < 0) { + $b = $x; + echo 'پاسخ محاسبه شده: ' . $x; + } else if (f($b) * f($x) < 0) { + $a = $x; + echo 'پاسخ محاسبه شده: ' . $x; + } else { + $stop = true; + echo 'پاسخ محاسبه شده: ' . $x; + } + $delta = abs($x - $oldx) / abs($x); + if ($delta < pow(10, -7)) { + $stop = true; + } + if ($stop) { + break; + } + $oldx = $x; + $m++; + } + } + ?> +
+
+
+
+ background
+
+
+ ریشه یابی - روش وتری +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-simpson.php b/method-simpson.php new file mode 100644 index 0000000..1454a87 --- /dev/null +++ b/method-simpson.php @@ -0,0 +1,181 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

انتگرال گیری عددی - روش سیمپسون

+

+ با وارد کردن تابع مورد نظر در فرم زیر، انتگرال آن نسبت به x با استفاده از روش سیمپسون 1/3 با تقسیم بازه وارد شده به بخش های کوچکتری (تعیین در فیلد تعداد نقاط میانی) محاسبه می‌شود. در صورت تمایل می‌توانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + + + dx +
+
+ + +
+
+ + +
+
+ + +
+ +
+

یا

+ +
+ تعداد نقاط میانی برابر با 20 درنظر گرفته شده است +
+
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function = $_POST["function"]; + $a = $_POST["a"]; + $b = $_POST["b"]; + $n = $_POST["n"]; + echo 'دامنه مدنظر: a = ' . $a . ' تا b = ' . $b . '
'; + echo 'تعداد نقاط میانی: n = ' . $n . ''; + echo 'تابع وارد شده: ∫(' . $function . ')dx
'; + $function = str_replace(' ', '', $function); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if ($prechar == 'x' || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if ($prechar !== 'x' && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if ($char == 'x' && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function = convert($function); + $function = str_replace('x', '$x', $function); + echo 'تابع ترجمه شده درون انتگرال: ' . $function . '
'; + function f($x) + { + global $function; + return eval("return $function;"); + } + $h = ($b - $a) / $n; + echo 'فاصله میان نقاط: h = (b - a) / n = ' . $h . '
'; + $m = 1; + $term2 = 0; + $term1 = 0 ; + $stop = false; + echo 'پاسخ محاسبه شده برای انتگرال با در نظر گرفتن نقطه آغازین'; + $result = ($h * f($a)) / 3; + echo "$result"; + while ($m < $n) { + echo '
پاسخ محاسبه شده برای انتگرال با در نظر گرفتن نقطه آغازین تا نقطه میانی ' . $m . ' ام'; + $term2 = (2 * $h * f($a + ($m * $h))) / 3; + $term1 = (4 * $h * f($a + ($m * $h))) / 3; + if ($m % 2 == 0) { + $result += $term2; + } else { + $result += $term1; + } + echo "$result"; + $m++; + } + echo '
پاسخ محاسبه شده برای انتگرال با در نظر گرفتن همه نقاط'; + $result += ($h * f($b)) / 3; + echo "$result"; + } + ?> +
+
+
+
+ background
+
+
+ انتگرال گیری عددی - روش سیمپسون +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/method-trapezoid.php b/method-trapezoid.php new file mode 100644 index 0000000..2cb94c0 --- /dev/null +++ b/method-trapezoid.php @@ -0,0 +1,174 @@ + + + + + + + + + +
+
→ بازگشت به فهرست
+

انتگرال گیری عددی - روش ذوزنقه ای مرکب

+

+ با وارد کردن تابع مورد نظر در فرم زیر، انتگرال آن نسبت به x با استفاده از روش ذوزنقه ای مرکب با تقسیم بازه وارد شده به بخش های کوچکتری (تعیین در فیلد تعداد نقاط میانی) محاسبه می‌شود. در صورت تمایل می‌توانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیش‌فرض برای محاسبات استفاده کنید. +

+
برای مشاهده پاسخ اسکرول کنید
+
+
+ + + + dx +
+
+ + +
+
+ + +
+
+ + +
+ +
+

یا

+ +
+ تعداد نقاط میانی برابر با 20 درنظر گرفته شده است +
+
+ راهنما + در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب + sin(تابع مدنظر) + و + cos(تابع مدنظر) + و + tan(تابع مدنظر) + و + sinh(تابع مدنظر) + و + cosh(تابع مدنظر) + باید وارد شوند. برای وارد کردن رادیکال از قالب + sqrt(تابع مدنظر) + و برای لگاریتم از قالب + log(تابع مدنظر,پایه لگاریتم) + استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت + 2x + یا + 2sin(x) + باید + 2*x + یا + 2*sin(x) + نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. +
+
+ .log, .message { display: flex; }'; + $function = $_POST["function"]; + $a = $_POST["a"]; + $b = $_POST["b"]; + $n = $_POST["n"]; + echo 'دامنه مدنظر: a = ' . $a . ' تا b = ' . $b . '
'; + echo 'تعداد نقاط میانی: n = ' . $n . ''; + echo 'تابع وارد شده: ∫(' . $function . ')dx
'; + $function = str_replace(' ', '', $function); + function convert($input) { + $output = ''; + for ($i = 0; $i < strlen($input); $i++) { + $char = $input[$i]; + if ($i !== strlen($input)) { + $nextchar = $input[$i + 1]; + } else { + $nextchar = null; + } + if ($i !== 0) { + $prechar = $input[$i - 1]; + } else { + $prechar = null; + } + if ($char == '(') { + if ($prechar == 'x' || is_numeric($prechar)) { + $addoperator = ' *'; + } else { + $addoperator = null; + } + } else if ($char == ')') { + if ($nextchar == '(' || is_numeric($nextchar) || ctype_alpha($nextchar)) { + $addoperator = '* '; + } else { + $addoperator = null; + } + } + if ($nextchar !== null && $prechar !== null) { + if ($char == '*' || $char == '/' || $char == '+' || $char == '-' || $char == '(' || $char == ')') { + if ($char == '(') { + if ($prechar !== 'x' && ctype_alpha($prechar)) { + $output .= $char . ' '; + } else { + $output .= $addoperator . ' ' . $char . ' '; + } + } else if ($char == ')') { + $output .= ' ' . $char . ' ' . $addoperator; + } else if ($char == '*' && $nextchar == '*') { + $output .= ' ' . $char; + } else if ($char == '*' && $prechar == '*') { + $output .= $char . ' '; + } else { + $output .= ' ' . $char . ' '; + } + } else if ($char == 'x' && is_numeric($prechar)) { + $output .= ' * ' . $char; + } else { + $output .= $char; + } + } else { + $output .= $char; + } + } + return $output; + } + $function = convert($function); + $function = str_replace('x', '$x', $function); + echo 'تابع ترجمه شده درون انتگرال: ' . $function . '
'; + function f($x) + { + global $function; + return eval("return $function;"); + } + $h = ($b - $a) / $n; + echo 'فاصله میان نقاط: h = (b - a) / n = ' . $h . '
'; + $m = 1; + $stop = false; + echo 'پاسخ محاسبه شده برای انتگرال با در نظر گرفتن نقطه آغازین'; + $result = ($h * f($a)) / 2; + echo "$result"; + while ($m < $n) { + echo '
پاسخ محاسبه شده برای انتگرال با در نظر گرفتن نقطه آغازین تا نقطه میانی ' . $m . ' ام'; + + $result += $h * f($a + ($m * $h)); + echo "$result"; + $m++; + } + echo '
پاسخ محاسبه شده برای انتگرال با در نظر گرفتن همه نقاط'; + $result += ($h * f($b)) / 2; + echo "$result"; + } + ?> +
+
+
+
+ background
+
+
+ انتگرال گیری عددی - روش ذوزنقه ای مرکب +
+

Numerical Analysis

+ + \ No newline at end of file diff --git a/numerical-analysis.css b/numerical-analysis.css new file mode 100644 index 0000000..d8f4add --- /dev/null +++ b/numerical-analysis.css @@ -0,0 +1,573 @@ +@font-face { + font-family: rezasadid; + src: url(https://rezasadid.com/files/data/vazir.ttf); +} + +::-webkit-scrollbar { + width: 10px !important; + height: 10px !important; +} + +::-webkit-scrollbar-track { + background: #7979df30 !important; +} + +::-webkit-scrollbar-thumb { + background: #7979df !important; +} + +* { + box-sizing: border-box; + font-family: rezasadid !important; +} + +body { + display: flex; + flex-direction: row; + width: 100vw; + height: 100vh; + padding: 0; + margin: 0; + background-color: #24242c; +} + +.pic { + width: 40%; + height: 100%; + overflow: hidden; +} + +.pic img { + object-fit: cover; + width: 100%; + height: 100%; +} + +.pic > div { + display: block; + width: 40%; + height: 100%; + position: absolute; + top: 0; + left: 0; + backdrop-filter: blur(40px); + background: #0000007d; +} + +.header { + background: #000000; + height: 90px; + width: 90px; + display: flex; + align-items: center; + flex-direction: row-reverse; + border-radius: 0 10px 10px 0; + position: fixed; + left: 0; + bottom: 20px; + transition: .4s; + z-index: 200; +} + +.header:hover { + width: 40%; + height: 100dvh; + bottom: 0; + border-radius: 0; +} + +video { + border-radius: 50%; + object-fit: contain; + width: 100%; + height: 100%; +} + +.page { + width: 60%; + height: 100dvh; + background-color: #24242c; + gap: 20px; + overflow-x: hidden; + overflow-y: auto; + padding: 20px; + display: inline-grid; + align-content: space-between; + align-items: start; +} + +.page > div { + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + gap: 20px; +} + +.page > *, +.page > div > * { + max-width: 100%; + margin: 0; +} + +h1 { + color: #fff; + text-align: center; +} + +p { + color: #8f9094; + text-align: center; +} + +.page > div > p { + text-align: justify; + text-align-last: center; +} + +code { + text-align: left; + direction: ltr; + margin: 0; + display: inline-flex; +} + +button { + text-wrap: nowrap; + overflow-x: auto; + overflow-y: hidden; + padding: 0 !important; +} + +button::-webkit-scrollbar { + width: 0 !important; + height: 0 !important; +} + +button code { + margin: 0 5px; +} + +.message { + background: #34344e; + color: #ffffff; + width: 100%; + height: 50px; + border-radius: 10px; + justify-content: center; + align-content: center; + align-items: center; + display: none; +} + +.inp { + width: 100%; + height: 50px; + max-height: 50px; + min-height: 50px; + display: flex; + align-items: center; + position: relative; +} + +.inp span:not(.inp label span) { + position: absolute; + color: #ffffff; + direction: ltr; + text-align: left; + left: 22px; + font-size: 15px; +} + +.inp span:not(.inp label span, .inp > span:nth-of-type(1)) { + left: unset; + right: 22px; +} + +.inp label { + position: absolute; + right: 20px; + left: unset !important; + color: #777780; + height: 20px; + padding-left: 5px; + cursor: text; + padding-right: 5px; + margin-top: -5px; + transition: .2s; +} + +.inp label:has(span) { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-content: flex-end; + justify-content: flex-end; + text-align: left; + direction: ltr; + align-items: baseline; +} + +.inp label span { + transform: scale(0.7); + display: inline-flex; + flex-direction: row; + align-content: flex-end; + justify-content: flex-start; + flex-wrap: nowrap; + direction: ltr; + text-align: left; + height: 100%; + align-items: flex-end; + position: relative; + top: 3px; +} + +.inp input { + width: 100%; + height: 100%; + background-color: transparent; + border: 2px solid #494954; + border-radius: 10px; + outline: none; + transition: .4s; + color: #fff; + padding-left: 20px; + padding-right: 20px; + font-size: 15px; + direction: ltr; + text-align: left; +} + +.inp input:focus { + border: 2px solid #1f1fff; + box-shadow: #6767ff 0px 1px 1px, #6767ff 0px 0px 0px 1px; +} + +.inp input:focus+label, +.inp.custom1 input+label, +.inp.custom2 input+label { + right: 20px; + transform: translateY(-22px); + font-size: 12px; + background-color: #24242c; +} + +.custom1 input, +.custom3 input { + padding-left: 36px; +} + +.custom2 input { + padding-left: 30px; + padding-right: 45px; +} + +.note { + font-size: 13px; + color: #9d9da7; + padding-right: 20px; + margin-top: -10px !important; + text-align: justify; + width: 100%; +} + +.note span { + font-size: 24px; + position: relative; + top: -5px; + margin-right: -20px; + height: 0; + display: block; +} + +.up { + left: 20px; + transform: translateY(-22px); + font-size: 12px; + background-color: #24242c; +} + +form { + display: flex; + flex-direction: column; + gap: 20px; + width: 100%; +} + +.separator { + display: flex; + align-items: baseline; + width: 100%; + margin: -20px 0px !important; +} + +.separator .line { + height: 3px; + flex: 1; + background-color: #8f9094; +} + +.separator p { + padding: 0 10px; +} + +.help { + background: #34344e; + padding: 20px; + border-radius: 10px; + color: #ffffffb3; + text-align: justify; + font-size: 13px; + line-height: 25px; +} + +.help span { + color: #34344e; + background: #ffffff; + font-weight: bold; + padding: 3px 20px 2px 8px; + border-radius: 8px 0 0 8px; + margin-right: -20px; + margin-left: 2px; +} + +.help code { + margin: 0; + background: #ffffff12; + border-radius: 7px; + padding: 0 5px; + height: 25px; + border: 2px solid #34344e; + align-items: center; + align-content: center; + justify-content: center; +} + +.log { + width: 100%; + display: none; + flex-direction: column; + align-items: flex-start; + align-content: center; + flex-wrap: nowrap; + background: #ffffff15; + border-radius: 10px; + padding: 20px; + color: #ffffff; + opacity: 0.8; +} + +.log hr { + width: 100%; +} + +.log code { + width: 100%; + background: #ffffff10; + border-left: 3px solid #ffffff; + padding-left: 5px; + margin: 5px 0; +} + +.footer { + display: flex !important; + flex-direction: row !important; + align-items: center !important; + justify-content: space-between !important; + align-content: flex-start !important; + width: 100%; + color: #d3d3d5; + border-top: 2px solid #e7edf5cf; + padding: 15px; + font-size: 11px; + padding: 20px 0 0px 0; + margin-top: 5px; +} + +.msg { + position: fixed; + width: 100%; + height: 40px; + padding: 10px 20px; + background: #07041e60; + backdrop-filter: blur(5px); + display: none; + align-content: center; + align-items: center; + justify-content: flex-start; + color: #ffffff; + font-size: 10px; + top: 90px; + text-align: justify; +} + +button, .button { + width: 100%; + height: 50px; + min-height: 50px; + max-height: 50px; + background-color: #6767ff; + border: none; + border-radius: 10px; + outline: none; + transition: .4s; + color: #fff; + padding-left: 20px; + padding-right: 20px; + font-size: 15px; + cursor: pointer; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-content: center; + justify-content: center; + align-items: center; + text-decoration: none; +} + +button:hover, .button:hover { + background-color: #1717c2; + border: none; +} + +.button span { + height: 30px; + width: 30px; + display: flex; + flex-direction: column; + align-content: center; + justify-content: center; + align-items: center; + background: rgb(255 255 255 / 20%); + border-radius: 20px; + margin: 10px; +} + +.back { + background: #ffffff21; + position: static; + top: 20px; + right: 20px; + width: fit-content; +} + +a:not(.button) { + color: #b7b7ff; + text-decoration: none; + transition: .4s; +} + +a:hover:not(.button:hover) { + color: #6d6df9; +} + +.fa { + font-family: rezasadid !important; + direction: rtl !important; +} + +.main { + position: fixed; + width: 40%; + left: 0; + bottom: calc(50dvh - 80px); + height: 160px; + z-index: 5; + font-size: 50px; + text-transform: uppercase; + letter-spacing: 5px; + display: flex; + align-items: center; + align-content: center; + justify-content: center; + flex-direction: column; + flex-wrap: nowrap; + text-shadow: 6px 4px black; +} + +@media only screen and (max-width: 750px) { + body { + flex-direction: column; + } + + .header { + top: 20px; + left: 20px; + border-radius: 10px !important; + bottom: unset !important; + } + + .header:hover { + width: 100% !important;; + height: 130px !important;; + top: 0 !important;; + left: 0 !important;; + } + + .help { + font-size: 10px !important; + } + + .pic { + height: 130px !important; + width: 100%; + order: 1; + overflow: visible !important; + } + + .pic > div { + width: 100%; + height: 130px; + } + + .back { + background: #6767ff; + position: fixed; + } + + .page { + width: 100%; + order: 2; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-content: center; + align-items: center; + flex-wrap: nowrap; + } + + .note span { + top: -10px; + } + + .footer { + flex-direction: column !important; + gap: 15px !important; + } + + .msg { + display: flex !important; + z-index: 100; + } + + .footer > a:nth-of-type(1) { + min-width: unset !important; + text-align: center !important; + margin-top: -2px; + } + + .main { + display: none; + top: 20px; + left: 130px; + font-size: 16px; + height: 50px; + align-items: flex-end; + flex-direction: column; + justify-content: center; + align-content: flex-end; + text-align: left; + text-shadow: 4px 3px black; + } +} \ No newline at end of file diff --git a/numerical-analysis.js b/numerical-analysis.js new file mode 100644 index 0000000..1436058 --- /dev/null +++ b/numerical-analysis.js @@ -0,0 +1,134 @@ +document.addEventListener("DOMContentLoaded", function () { + const inputs = document.querySelectorAll(".inp input"); + + inputs.forEach(input => { + input.addEventListener("input", function () { + const label = this.nextElementSibling; + label.classList.toggle("up", this.value.trim() !== ""); + }); + }); +}); + +function focusinp(inp) { + if (inp == 'v1') { + document.getElementById("v1").focus(); + } else if (inp == 'v2') { + document.getElementById("v2").focus(); + } else if (inp == 'v3') { + document.getElementById("v3").focus(); + } else if (inp == 'v4') { + document.getElementById("v4").focus(); + } else if (inp == 'v5') { + document.getElementById("v5").focus(); + } else if (inp == 'v6') { + document.getElementById("v6").focus(); + } else if (inp == 'v7') { + document.getElementById("v7").focus(); + } else if (inp == 'v8') { + document.getElementById("v8").focus(); + } else if (inp == 'v9') { + document.getElementById("v9").focus(); + } +} + +function methodbisection () { + var predefinedValues = { + function: "(2x+5)*sin(x)+5", + a: 0, + b: 5 + }; + document.getElementById("v1").value = predefinedValues.function; + document.getElementById("v2").value = predefinedValues.a; + document.getElementById("v3").value = predefinedValues.b; + document.querySelector("#mainform button[type='submit']").click(); +} + +function methodfalseposition() { + var predefinedValues = { + function: "(2x+5)*sin(x)+5", + a: 0, + b: 5 + }; + document.getElementById("v1").value = predefinedValues.function; + document.getElementById("v2").value = predefinedValues.a; + document.getElementById("v3").value = predefinedValues.b; + document.querySelector("#mainform button[type='submit']").click(); +} + +function methodfixedpointiteration() { + var predefinedValues = { + function: "((2x+5)*sin(x)+6+100x)/100", + a: 0, + b: 5, + initial: 0 + }; + document.getElementById("v1").value = predefinedValues.function; + document.getElementById("v2").value = predefinedValues.a; + document.getElementById("v3").value = predefinedValues.b; + document.getElementById("v4").value = predefinedValues.initial; + document.querySelector("#mainform button[type='submit']").click(); +} + +function methodnewtonraphson() { + var predefinedValues = { + function: "(2x+5)*sin(x)+5", + functionderivative: "(2*sin(x))+((2*x+5)*cos(x))", + initial: 3 + }; + document.getElementById("v1").value = predefinedValues.function; + document.getElementById("v2").value = predefinedValues.functionderivative; + document.getElementById("v3").value = predefinedValues.initial; + document.querySelector("#mainform button[type='submit']").click(); +} + +function methodsecant() { + var predefinedValues = { + function: "(2x+5)*sin(x)+5", + a: 3, + b: 4 + }; + document.getElementById("v1").value = predefinedValues.function; + document.getElementById("v2").value = predefinedValues.a; + document.getElementById("v3").value = predefinedValues.b; + document.querySelector("#mainform button[type='submit']").click(); +} + +function methodtrapezoid() { + var predefinedValues = { + function: "(2x+5)*sin(x)+5", + a: 0, + b: 5, + n: 20 + }; + document.getElementById("v1").value = predefinedValues.function; + document.getElementById("v2").value = predefinedValues.a; + document.getElementById("v3").value = predefinedValues.b; + document.getElementById("v4").value = predefinedValues.n; + document.querySelector("#mainform button[type='submit']").click(); +} + +function methodsimpson() { + var predefinedValues = { + function: "(2x+5)*sin(x)+5", + a: 0, + b: 5, + n: 20 + }; + document.getElementById("v1").value = predefinedValues.function; + document.getElementById("v2").value = predefinedValues.a; + document.getElementById("v3").value = predefinedValues.b; + document.getElementById("v4").value = predefinedValues.n; + document.querySelector("#mainform button[type='submit']").click(); +} + +function methodjacobi() { + var predefinedValues = { + function1: "(2-y-z)/7", + function2: "(5-(2*x)+(6*z))/15", + function3: "(8-(2*x)+(y))/5" + }; + document.getElementById("v1").value = predefinedValues.function1; + document.getElementById("v2").value = predefinedValues.function2; + document.getElementById("v3").value = predefinedValues.function3; + document.querySelector("#mainform button[type='submit']").click(); +} \ No newline at end of file