-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial upload of Numerical Analysis Tools project files
- Loading branch information
1 parent
774b4c7
commit 3e9574d
Showing
12 changed files
with
2,248 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
<div align="center"> | ||
<a href="https://github.com/rezasadid753/numerical-analysis-tools"><video width="80" height="80" autoplay="" loop="" muted="" __idm_id__="3686401"><source src="https://rezasadid.com/files/data/rs-logo-long.mp4" type="video/mp4">Reza Sadid</video></a> | ||
<h3 align="center">Numerical Analysis Tools</h3> | ||
<p align="center"> | ||
Explore practical implementations of numerical analysis methods in PHP | ||
</p> | ||
<a href="https://rsdn.ir/g-nas">View Demo</a> | ||
· | ||
<a href="https://github.com/rezasadid753/numerical-analysis-tools/issues">Report an Issue or Request a Feature</a> | ||
· | ||
<a href="https://github.com/rezasadid753/numerical-analysis-tools/pulls">Collaborate</a> | ||
</div> | ||
|
||
<br> | ||
|
||
## 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. | ||
|
||
 | ||
|
||
### 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: [email protected], [email protected] | ||
* Phone: +98 21 9130 2492 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!doctype html> | ||
<html dir="rtl" lang="fa-IR"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="numerical-analysis.css"> | ||
<script src="numerical-analysis.js"></script> | ||
</head> | ||
<body style="direction: rtl;"> | ||
<div class="header"><video width="80" height="80" autoplay loop muted><source src="https://rezasadid.com/files/data/rs-logo-long.mp4" type="video/mp4" />Reza Sadid</video></div> | ||
<div class="page"><h1 class="fa">فهرست</h1><div> | ||
<div class="separator"><div class="line"></div><p>ریشه یابی</p><div class="line"></div></div> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-bisection.php">روش دوبخشی</a> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-false-position.php">روش نابجایی</a> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-fixed-point-iteration.php">روش تکرار ساده</a> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-newton-raphson.php">روش نیوتون</a> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-secant.php">روش وتری</a> | ||
<div class="separator"><div class="line"></div><p>حل دستگاه معادلات خطی</p><div class="line"></div></div> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-jacobi.php">روش ژاکوبی</a> | ||
<div class="separator"><div class="line"></div><p>انتگرال گیری عددی</p><div class="line"></div></div> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-trapezoid.php">روش ذوزنقه ای مرکب</a> | ||
<a class="button fa" href="https://rezasadid.com/projects/numericalanalysis/method-simpson.php">روش سیمپسون</a> | ||
</div><div class="footer">طراحی و توسعه داده شده توسط رضا سدید<a href="mailto:[email protected]" style="min-width: calc(100% - 325px); text-align: left;">[email protected]</a><a href="tel:02191302492">021-91302492</a></div> | ||
</div> | ||
<div class="pic"> | ||
<img src="https://rezasadid.com/files/data/pattern-background.gif" alt="background" loop=infinite/><div></div> | ||
</div> | ||
<div class="msg"> | ||
محاسبات عددی | ||
</div> | ||
<h1 class="fa main" style="display: flex !important;">Numerical Analysis</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
<!doctype html> | ||
<html dir="rtl" lang="fa-IR"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="numerical-analysis.css"> | ||
<script src="numerical-analysis.js"></script> | ||
</head> | ||
<body style="direction: rtl;"> | ||
<div class="header"><video width="80" height="80" autoplay loop muted><source src="https://rezasadid.com/files/data/rs-logo-long.mp4" type="video/mp4" />Reza Sadid</video></div> | ||
<div class="page"><a class="button fa back" href="https://rezasadid.com/projects/numericalanalysis/">→ بازگشت به فهرست</a><div> | ||
<h1 class="fa">ریشه یابی - روش دوبخشی</h1> | ||
<p> | ||
با وارد کردن تابع مورد نظر در فرم زیر، یکی از ریشههای آن در دامنه تعیینشده با استفاده از روش دوبخشی محاسبه میشود. تکرارها تا زمانی که 7 رقم بامعنا پاسخ ثابت بماند ادامه مییابد و در نهایت ریشه تابع با تقریب بدست میآید. در صورت تمایل میتوانید تابع دلخواه خود را در فرم وارد کنید یا با کلیک بر روی دکمه پایین فرم، از یک تابع پیشفرض برای محاسبات استفاده کنید. | ||
</p> | ||
<div class="message">برای مشاهده پاسخ اسکرول کنید</div> | ||
<form id="mainform" method="post" action=""> | ||
<div class="inp"> | ||
<input type="text" name="function" id="v1"> | ||
<label onclick="focusinp('v1')" for="v1">تابع</label> | ||
</div> | ||
<div class="inp"> | ||
<input type="text" name="a" id="v2"> | ||
<label onclick="focusinp('v2')" for="v2">ابتدای دامنه</label> | ||
</div> | ||
<div class="inp"> | ||
<input type="text" name="b" id="v3"> | ||
<label onclick="focusinp('v3')" for="v3">انتهای دامنه</label> | ||
</div> | ||
<button type="submit">ثبت</button> | ||
</form> | ||
<div class="separator"><div class="line"></div><p>یا</p><div class="line"></div></div> | ||
<button type="button" onclick="methodbisection()">محاسبه ریشه تابع <code>(2x+5)*sin(x)+5</code> در بازه 0 تا 5</button> | ||
<div class="help"> | ||
<span>راهنما</span> | ||
در وارد کردن تابع توجه کنید که برای اپراتور جمع از + و برای اپراتور تفریق از - و برای اپراتور ضرب از * و برای اپراتور تقسیم از / و برای اپراتور توان از ** استفاده نمائید، همچنین میتواند از توابع مثلثاتی مانند سینوس و کسینوس و تانژانت و سینوس هیپربولیک و کسینوس هیپربولیک نیز استفاده کنید که به ترتیب در قالب | ||
<code>sin(تابع مدنظر)</code> | ||
و | ||
<code>cos(تابع مدنظر)</code> | ||
و | ||
<code>tan(تابع مدنظر)</code> | ||
و | ||
<code>sinh(تابع مدنظر)</code> | ||
و | ||
<code>cosh(تابع مدنظر)</code> | ||
باید وارد شوند. برای وارد کردن رادیکال از قالب | ||
<code>sqrt(تابع مدنظر)</code> | ||
و برای لگاریتم از قالب | ||
<code>log(تابع مدنظر,پایه لگاریتم)</code> | ||
استفاده نمائید. در وارد کردن تابع توجه نمائید که اپراتور ضرب را حتما بین ارقام و متغیر ها درج نمائید برای مثال بجای عبارت | ||
<code>2x</code> | ||
یا | ||
<code>2sin(x)</code> | ||
باید | ||
<code>2*x</code> | ||
یا | ||
<code>2*sin(x)</code> | ||
نوشته شود تا تابع پس از ترجمه مطابق با سینتکس پی اچ پی باشد. درصورتی که پس از ثبت تابع روند تکرار نمایش داده نشد تابع خود را تصحیح کنید و یا از دکمه پایین آن استفاده نمائید که بمنظور سهولت روند تست تابعی پیشفرض با کلیک بر روی آن در فرم قرار میگیرد و میتوانید روند محاسبات را مشاهده نمائید. | ||
</div> | ||
<div class="log"> | ||
<?php | ||
if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
echo '<style>.log, .message { display: flex; }</style>'; | ||
$function = $_POST["function"]; | ||
$a = $_POST["a"]; | ||
$b = $_POST["b"]; | ||
echo 'دامنه مدنظر: ' . $a . ' تا ' . $b . '<hr>'; | ||
echo 'تابع وارد شده: <code>' . $function . '</code><hr>'; | ||
$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 'تابع ترجمه شده: <code>' . $function . '</code>'; | ||
function f($x) | ||
{ | ||
global $function; | ||
return eval("return $function;"); | ||
} | ||
$m = 0; | ||
$prec = null; | ||
$stop = false; | ||
while ($m < 100) { | ||
$c = ($a + $b) / 2; | ||
echo '<hr> تکرار شماره ' . $m . '<code>a=' . $a . ', b=' . $b . ', c=' . $c . ', f(a)=' . f($a) . ', f(c)=' . f($c) . '</code>'; | ||
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; | ||
} | ||
} | ||
?> | ||
</div> | ||
</div><div class="footer">طراحی و توسعه داده شده توسط رضا سدید<a href="mailto:[email protected]" style="min-width: calc(100% - 325px); text-align: left;">[email protected]</a><a href="tel:02191302492">021-91302492</a></div> | ||
</div> | ||
<div class="pic"> | ||
<img src="https://rezasadid.com/files/data/pattern-background.gif" alt="background" loop=infinite/><div></div> | ||
</div> | ||
<div class="msg"> | ||
ریشه یابی - روش دوبخشی | ||
</div> | ||
<h1 class="fa main">Numerical Analysis</h1> | ||
</body> | ||
</html> |
Oops, something went wrong.