JavaScript Math.exp(x) – বাংলা টিউটোরিয়াল
Math.exp(x) একটি বিল্ট-ইন জাভাস্ক্রিপ্ট মেথড যা ex বা প্রাকৃতিক ঘাত (exponential) হিসাব করে দেয়। এখানে e হচ্ছে Euler’s সংখ্যা যার মান প্রায় 2.718।
গঠন (Syntax):
Math.exp(x)
প্যারামিটার: একটি সংখ্যা x, যেটির ঘাতরূপে e ব্যবহৃত হবে।
রিটার্ন ভ্যালু: ex এর মান।
উদাহরণ ১: সাধারণ সংখ্যা
<script>
let result = Math.exp(1);
console.log(result); // Output: প্রায় 2.718
</script>
let result = Math.exp(1);
console.log(result); // Output: প্রায় 2.718
</script>
✍️ এখানে Math.exp(1) মানে হচ্ছে e^1, অর্থাৎ e এর আসল মান প্রিন্ট হবে।
উদাহরণ ২: x = 2
<script>
let result = Math.exp(2);
console.log(result); // Output: প্রায় 7.389
</script>
let result = Math.exp(2);
console.log(result); // Output: প্রায় 7.389
</script>
✍️ কারণ e^2 ≈ 7.389। এটি একটি ঘাতমূল সংখ্যা।
উদাহরণ ৩: ঋণাত্মক সংখ্যা
<script>
let result = Math.exp(-1);
console.log(result); // Output: প্রায় 0.3679
</script>
let result = Math.exp(-1);
console.log(result); // Output: প্রায় 0.3679
</script>
✍️ এখানে e-1 ≈ 1/e ≈ 0.3679। এটি বিপরীত ঘাত নির্দেশ করে।
টেবিল: বিভিন্ন x এর জন্য Math.exp(x) মান
| x | exp(x) | ব্যাখ্যা |
|---|---|---|
| 0 | 1 | e⁰ = 1 |
| 1 | 2.718 | প্রাকৃতিক সংখ্যা e |
| 2 | 7.389 | e² |
| -1 | 0.3679 | 1/e |
কোথায় ব্যবহার হয় Math.exp(x)?
- Growth বা decay মডেল (যেমন interest, population growth)
- Scientific simulation (radioactive decay)
- Machine Learning-এর sigmoid function, softmax ইত্যাদিতে
- Mathematical modeling ও signal processing-এ
⚠️ সতর্কতা:
- exp(x) দ্রুত বড় হয়ে যায়, তাই বড় x দিলে Infinity রিটার্ন হতে পারে।
- Floating-point limitations এর কারণে decimal এ সঠিকতা সবসময় থাকবে না।