09-10-15, 11:03 PM
(آخر تعديل لهذه المشاركة : 09-10-15, 11:19 PM {2} بواسطة الشاكي لله.)
انتهت الجولة الاولى
النتائج توجد هنا
الحل
PHP كود :
/// <summary>
/// Find Tangent Line Equation of function on specific point
/// </summary>
/// <param name="function">string of cupic function</param>
/// <param name="atPoint">x coordinate of tangent</param>
/// <returns>Equation of Tangent Line</returns>
/// This Algorithm wrote by Mohammed Almubarak (vb4arb)
static string FindTangentLineEquation(string function, int atPoint)
{
string output;
#region Input Processing
//function string processing (get terms)
string equation = function.Split('=')[1];
string[] terms = Regex.Split(equation, @"(?=[+-])");
//remove any space
for (int i = 0; i < terms.Length; i++)
terms[i] = terms[i].Replace(" ", "");
#endregion
#region Algorithm Processing
//Algorithm processing ( 1-Find Slope, 2-Find Y )
double slope = 0;
double y = 0;
/*
* 1-Find Slope
*/
foreach (string term in terms)
{
if (term.Trim() != string.Empty)
{
//if term has power
if (term.IndexOf('^') > -1)
{
double power, coefficient;
power = double.Parse(term.Split('^')[1].Trim());
coefficient = double.Parse(term.Split('x')[0].Trim());
//find derivative of term and plug in
slope += (coefficient * power) * Math.Pow(atPoint, (power - 1));
}
else if (term.IndexOf('x') > -1)
{
//find derivative of term and plug in
double coefficient = double.Parse(term.Split('x')[0].Trim());
slope += coefficient;
}
}
}
/*
* 2-Find Y
*/
foreach (string term in terms)
{
if (term.Trim() != string.Empty)
{
//if term has power
if (term.IndexOf('^') > -1)
{
double power, coefficient;
power = double.Parse(term.Split('^')[1].Trim());
coefficient = double.Parse(term.Split('x')[0].Trim());
//find derivative of segment and plug in
y += (coefficient) * Math.Pow(atPoint, power);
}
else if (term.IndexOf('x') > -1)
{
//find derivative of term and plug in
double coefficient = double.Parse(term.Split('x')[0].Trim());
y += coefficient * atPoint;
}
else
{
double constantNumber = double.Parse(term);
y += constantNumber;
}
}
}
#endregion
#region Output
//output
/*
* Plug in Equation (y = mx + c)
*/
double c = (slope * -1 * atPoint) + (y);
output = "y = " + slope + "x " + c.ToString("+ #;- #;0");
#endregion
return output;
}
طبعا خط المماس هو الخط الذي يمس منحنى الدالة عن نقطة معينة :-
برمجيا: كيف استفاد المبرمجين من خط المماس ومعادلاته ؟
استفاد منه المبرمجين في صنع مايسمى بالbezier curve وهذه الميزة موجودة في جميع برامج الرسم بدأ بالphotoshop والillustrator وانتهاء ببرامج التصميم الثلاثية الابعاد :
----------------
في النهاية ، طريقة الحل موجودة في هذه الصفحة :-
http://www.wikihow.com/Find-the-Equation-of-a-Tangent-Line

