Given an ellipse centered at **(h, k)**, with semi-major axis **a**, semi-minor axis **b**, both aligned with the Cartesian plane. The task is to determine if the point **(x, y)** is within the area bounded by the ellipse.

**Examples:**

Input: h = 0, k = 0, x = 2, y = 1, a = 4, b = 5 Output: Inside Input: h = 1, k = 2, x = 200, y = 100, a = 6, b = 5 Output: Outside

**Approach**: We have to solve the equation of ellipse for the given point **(x, y)**,

(x-h)^2/a^2 + (y-k)^2/b^2 <= 1

If in the inequation, results comes **less than 1** then the point lies **within**, else if it comes **exact 1** then the point **lies on the ellipse**, and if the inequation is **unsatisfied** then point **lies outside of the ellipse**.

**Below is the implementation of the above approach**:

## C++

`// C++ Program to check if the point ` `// lies within the ellipse or not ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to check the point ` `int` `checkpoint(` `int` `h, ` `int` `k, ` `int` `x, ` `int` `y, ` `int` `a, ` `int` `b) ` `{ ` ` ` ` ` `// checking the equation of ` ` ` `// ellipse with the given point ` ` ` `int` `p = (` `pow` `((x - h), 2) / ` `pow` `(a, 2)) ` ` ` `+ (` `pow` `((y - k), 2) / ` `pow` `(b, 2)); ` ` ` ` ` `return` `p; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `h = 0, k = 0, x = 2, y = 1, a = 4, b = 5; ` ` ` ` ` `if` `(checkpoint(h, k, x, y, a, b) > 1) ` ` ` `cout << ` `"Outside"` `<< endl; ` ` ` ` ` `else` `if` `(checkpoint(h, k, x, y, a, b) == 1) ` ` ` `cout << ` `"On the ellipse"` `<< endl; ` ` ` ` ` `else` ` ` `cout << ` `"Inside"` `<< endl; ` ` ` ` ` `return` `0; ` `} ` |

## PHP

`<?php ` `// PHP Program to check if the point ` `// lies within the ellipse or not ` ` ` `// Function to check the point ` `function` `checkpoint(` `$h` `, ` `$k` `, ` `$x` `, ` ` ` `$y` `, ` `$a` `, ` `$b` `) ` `{ ` ` ` ` ` `// checking the equation of ` ` ` `// ellipse with the given point ` ` ` `$p` `= (pow((` `$x` `- ` `$h` `), 2) / pow(` `$a` `, 2)) + ` ` ` `(pow((` `$y` `- ` `$k` `), 2) / pow(` `$b` `, 2)); ` ` ` ` ` `return` `$p` `; ` `} ` ` ` `// Driver code ` `$h` `= 0; ` `$k` `= 0; ` `$x` `= 2; ` `$y` `= 1; ` `$a` `= 4; ` `$b` `= 5; ` ` ` `if` `(checkpoint(` `$h` `, ` `$k` `, ` `$x` `, ` `$y` `, ` `$a` `, ` `$b` `) > 1) ` ` ` `echo` `(` `"Outside"` `); ` ` ` `else` `if` `(checkpoint(` `$h` `, ` `$k` `, ` `$x` `, ` `$y` `, ` `$a` `, ` `$b` `) == 1) ` ` ` `echo` `(` `"On the ellipse"` `); ` ` ` `else` ` ` `echo` `(` `"Inside"` `) ; ` ` ` `// This code is contributed by Shivi_Aggarwal ` `?> ` |

**Output:**

Inside

## Recommended Posts:

- Check if a point is inside, outside or on the parabola
- Find four factors of N with maximum product and sum equal to N | Set 3
- Check if two arrays are permutations of each other using Mathematical Operation
- Check if the given 2-D points form T-shape or not
- Area of a circle inscribed in a regular hexagon
- Find area of triangle if two vectors of two adjacent sides are given
- Area of the Largest square that can be inscribed in an ellipse
- Length of longest rod that can fit into a cuboid
- Largest triangle that can be inscribed in a semicircle
- Area of Largest rectangle that can be inscribed in an Ellipse
- Find any pair with given GCD and LCM
- Maximum distinct lines passing through a single point
- Smallest square formed with given rectangles
- Find if a point lies inside a Circle
- How to check if a given point lies inside or outside a polygon?

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.