

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find Tangent at a given point on the curve in C++
Suppose we have a curve like y = x(A - x), we have to find the tangent at a given point (x,y) on that curve. Here A is an integer number, x and y are also integers.
To solve this, we have the check that the given point is on the curve or not, if so, then find the differentiation of that curve, so it will be −
$$\frac{\text{d}y}{\text{d}x}=A-2x$$
Then put x and y into the dy/dx, then find the tangent using this equation −
$$Y-y=-\lgroup\frac{\text{d}y}{\text{d}x}\rgroup*\lgroup X-x \rgroup$$
Example
#include<iostream> using namespace std; void getTangent(int A, int x, int y) { int differentiation = A - x * 2; if (y == (2 * x - x * x)) { if (differentiation < 0) cout << "y = " << differentiation << "x" << (x * differentiation) + (y); else if (differentiation > 0) cout << "y = " << differentiation << "x+" << -x * differentiation + y; else cout << "Not possible"; } } int main() { int A = 2, x = 2, y = 0; cout << "Equation of tangent is: "; getTangent(A, x, y); }
Output
Equation of tangent is: y = -2x-4
- Related Questions & Answers
- Find normal at a given point on the curve in C++
- Java Program to Determine the Unicode Code Point at a given index
- Get the hyperbolic tangent of a given value in Java
- Get the arc tangent of a given value in Java
- C++ program to find the best fit rectangle that covers a given point
- Find the arrangement of queue at given time in C++
- Find middle point segment from given segment lengths in C++
- Find a Fixed Point (Value equal to index) in a given array in C++
- Check whether the point (x, y) lies on a given line in Python
- Find a Fixed Point (Value equal to index) in a given array in C++ Program
- Angle between a chord and a tangent when angle in the alternate segment is given in C++?
- Find a partition point in array in C++
- Find nth term of the Dragon Curve Sequence in C++
- Find bitonic point in given bitonic sequence in Python
- Find the other end point of a line with given one end and mid using C++
Advertisements