text:
Solving Simultaneous Equations Using Graphs Worksheets | MME

# Solving Simultaneous Equations with Graphs Worksheets, Questions and Revision

Level 6-7

## Solving Simultaneous Equations using Graphs

Two equations are simultaneous  if they are both true at the same time and for the same values of $x$ and $y$.

Simultaneous equations can be solved using algebra, but here we’re going to go through the process of solving them using graphs.

There are 2 types of simultaneous equations you need to know about.

Make sure you are happy with the following topics before continuing:

KS3 Level 4-5

## Type 1: Two Linear Graphs

It is possible to solve linear simultaneous equations with graphs by finding where they intersect.

Example: By plotting their graphs, for values of $x$ between $-1$ and $4$, on the same axes, find the solution to the two simultaneous equations below.

\begin{aligned}y&=2x-5 \\ y&=-x+4\end{aligned}

Step 1: Plot both straight line graphs on the same axes.

Step 2: Look for where the graphs intersect.

As we can see, these straight lines cross at $1$ point  (circled in red).

The coordinates of this point, $(3, 1)$, provide the solution to this problem.

Therefore, the solution is

$x=3,\,\,\,y=1$

KS3 Level 4-5
Level 6-7

## Type 2: Linear and Non-Linear Graphs

Like linear simultaneous equations, non-linear simultaneous equations can also be solved by finding the intersection point, however this time there are two solutions.

Example: By plotting their graphs on the same axes, find the solution to the two simultaneous equations below.

$\textcolor{blue}{y=x+2}$

$\textcolor{red}{x^2+y^2 =100}$

[3 marks]

Step 1: Plot both the straight line graph and the circle graph on the same axes.

Step 2: Look for where the graphs intersect (circled in green).

As this is a linear and non-linear problem, there will more more than $1$ intersection.  In this case there will be $2$

As we can see, the two graphs intersect at the following coordinates:

$(6,8)$ and $(-8, -6)$

Therefore, the two solutions to the equations are

$x=6,\,\,\,y=8$ and $x=-8,\,\,\,y=-6$

Level 6-7

## GCSE Maths Revision Cards

(242 Reviews) £8.99

### Example Questions

So, we want $3$ points in order to plot each line. Subbing in some values of $x$ into the first equation, we get

$x=-2$ gives $y=-2\times (-2)+1=5$

$x=0$ gives $y=-2\times (0)+1=-1$

$x=3$ gives $y=-2\times (3)+1=-5$

So, our $3$ coordinates to plot are

$(-2, 5),\,\,(0, -1),\,\,(3, -5)$

Then, doing the same for the second equation, we get

$x=-2$ gives $y=-(-2)-1=1$

$x=0$ gives $y=-(0)-1=-1$

$x=3$ gives $y=-(3)-1=-4$

So, our $3$ coordinates to plot are

$(-2, 1),\,\,(0, -1),\,\,(3, -4)$

Plotting these points and drawing the lines, we get the graph shown below.

As we can see, the coordinates where the lines cross are $(2, -3)$. Therefore, the solution is

$x=2,\,\,\,\,\,y=-3$

Before we can plot any points, we need to rearrange the second equation to be in a form we can use. So, subtracting $3x$ from both sides, we get

$2y=-3x-3$

Then, dividing both sides by $2$ we get the desired form:

$y=-1.5x-1.5$

Now we’ve sorted that out, we want $3$ points in order to plot each line. Subbing in some values of $x$ into the first equation, we get

$x=-3$ gives $y=2\times (-3)+2=-4$

$x=0$ gives $y=2\times (0)+2=2$

$x=2$ gives $y=2\times (2)+2=6$

So, our $3$ coordinates to plot are

$(-3, -4),\,\,(0, 2),\,\,(2, 6)$

Then, doing the same for the (rearranged) second equation, we get

$x=-3$ gives $y=-1.5 \times (-3)-1.5=3$

$x=0$ gives $y=-1.5 \times (0)-1.5=-1.5$

$x=1$ gives $y=-1.5 \times (1)-1.5=-3$

So, our $3$ coordinates to plot are

$(-3, 3),\,\,(0, -1.5),\,\,(1, -3)$

Plotting these points and drawing the lines, we get the graph shown below.

As we can see, the coordinates where the lines cross are $(-1, 0)$. Therefore, the solution is

$x=-1,\,\,\,\,\,y=0$

The process for this will be exactly the same as the last one with one extra step right here at the beginning. The second equation is written it an unusual form, and in order to be able to substitute $x$ values into it, we need to have it written in the form $”y=...”$.

So, we must rearrange! Firstly, subtract $x$ from both sides to get

$3y=-x-4$

Then, divide both sides by 3 to get

$y=-\dfrac{1}{3}x-\dfrac{4}{3}$

Yikes, this is pretty unpleasant. That’s okay, we have a calculator. Remember, we only need $3$ points, so try substituting in different values of $x$ with your calculator until you get some nice whole number answers (just to make plotting easier). Doing this, we get

$x=-4 \text{ gives } y=-\dfrac{1}{3}\times (-4)-\dfrac{4}{3}=0$

$x=-1 \text{ gives } y=-\dfrac{1}{3}\times (-1)-\dfrac{4}{3}=-1$

$x=2 \text{ gives } y=-\dfrac{1}{3}\times (2)-\dfrac{4}{3}=-2$

So, our $3$ coordinates to plot are

$(-4, 0),\,\,(-1, -1),\,\,(2, -2)$

Then, for the second equation, our three $y$ values will be

$x=-4$ gives $y=-4+2=-2$

$x=0$ gives $y=0+2=2$

$x=2$ gives $y=2+2=4$

So, our $3$ coordinates to plot are

$(-4, -2),\,\,(0, 2),\,\,(2, 4)$

Plotting these points and drawing the lines, we get the graph shown below.

Looking at where the graphs cross, we can see that – whilst the coordinates of it are not whole numbers – the point is halfway between $-2$ and $-3$ on the $x$ axis and halfway between $0$ and $-1$ on the $y$ axis.

So, it’s coordinates are: $(-2.5, -0.5)$, and therefore the solution is

$x=-2.5,\,\,\,y=-0.5$

NOTE: This will only be clear if the graphs are drawn as accurately as possible. Rough sketches of lines will not give you accurate solutions.

### Worksheets and Exam Questions

#### Solving Simultaneous Equations with Graphs

Level 6-7 New Official MME

Level 6-7

Level 1-3

### Learning resources you may be interested in

We have a range of learning resources to compliment our website content perfectly. Check them out below.


text:
29. Van der Grinten projection

# VAN DER GRINTEN PROJECTION #

## SUMMARY #

• Neither equal-area nor conformal. Not pseudocylindrical.
• Shows entire globe enclosed in a circle.
• Central meridian and Equator are straight lines.
• All other meridians and parallels are arcs of circles.
• A curved modification of the Mercator projection, with great distortion in the polar areas.
• Equator is true to scale.
• Used for world maps.
• Used only in the spherical form.
• Presented by van der Grinten in 1904.

## HISTORY, FEATURES, AND USAGE #

In a 1904 issue of a German geographical journal, Alphons J. van der Grinten (1852-?) of Chicago presented four projections showing the entire Earth. Aside from having a straight Equator and central meridian, three of the projections consist of arcs of circles for meridians and parallels; the other projection has straight-line parallels. The projections are neither conformal nor equal-area (van der Grinten, 1904; 1905). They were patented in the United States by van der Grinten in 1904.

The best-known Van der Grinten projection, his first (fig. 52), shows the world in a circle and was invented in 1898. It is designed for use in the spherical form only. There are no special features to preserve in an ellipsoidal form. It has been used by the National Geographic Society for their standard world map since 1943, printed at various scales and with the central meridian either through America or along the Greenwich meridian; this use has prompted others to employ the projection. The U.S. Department of Agriculture adopted the projection as the base map for economic data in the 1940’s, and this led to frequent use in geography textbooks (Wong, 1965, p. 117). The USGS has used one of the National Geographic maps as a base for a four-sheet set of maps of World Subsea Mineral Resources, 1970, one at a scale of 1:60,000,000 and three at 1:39,283,200 (a scale used by the National Geographic), and for three smaller maps in the National Atlas (USGS, 1970, p. 150-151, 332-335). All the USGS maps have a central meridian of long. 85° W., passing through the United States.

Van der Grinten emphasized that this projection blends the Mercator appearance with the curves of the Mollweide, an equal-area projection described later. He included a simple graphical construction and limited formulas showing the mathematical coordinates along the central meridian, the Equator, and the outer (180th) meridian. The meridians are equally spaced along the Equator, but the spacing between the parallels increases with latitude, so that the 75th parallels are shown about halfway between the Equator and the respective poles. Because of the polar exaggerations, most published maps using the Van der Grinten projection do not extend farther into the polar regions than the northern shores of Greenland and the outer rim of Antarctica.

The National Geographic Society prepared the base map graphically. General mathematical formulas have been published in recent years and are only useful with computers, since they are fairly complex for such a simply drawn projection (O’Keefe and Greenberg, 1977; Snyder, 1979b).

## GEOMETRIC CONSTRUCTION #

The meridians are circular arcs equally spaced on the Equator and joined at the poles. For parallels, referring to figure 53, semicircle CDB is drawn centered at A. Diagonal CD is drawn. Point E is marked so that the ratio of EA to AD is the same as the ratio of the latitude to 90°. Line FE is drawn parallel to CB, and FB and GB are connected. At H, the intersection of GB and AD, JHL is drawn parallel to CB. A circular arc, representing the parallel of latitude, is then drawn through JKL.

## FORMULAS FOR THE SPHERE #

The general formulas published are in two forms. Both sets give identical results, but the 1979 formulas are somewhat shorter and are given here with some rearrangement and addition of new inverse equations. For the forward calculations, given $R, \lambda_0, \phi,$ and $\lambda$ (giving true scale along the Equator), to find $x$ and $y$ (see p. 363 for numerical examples): $$x = \pm\pi R\{A(G-P^2)+[A^2(G-P^2)^2-(P^2+A^2)(G^2-P^2)]^{1/2}\}/(P^2+A^2) \tag{ 29-1 }$$ taking the sign of $(\lambda-\lambda_0)$. Note that $(\lambda-\lambda_0)$ must fall between +180° and -180°; if necessary, 360° must be added or subtracted. The X axis lies along the Equator, x increasing easterly, while the Y axis coincides with the central meridian $\lambda_0$. $$y=\pm\pi R\{P Q - A[(A^2+1)(P^2+A^2)-Q^2]^{1/2}\}/(P^2+A^2) \tag{ 29-2 }$$ taking the sign of $\phi$,

where $$A = ½|\pi/(\lambda-\lambda_0)-(\lambda-\lambda_0)/\pi | \tag{ 29-3 }$$ $$G = \cos\theta/(\sin\theta+\cos\theta-1) \tag{ 29-4 }$$ $$P = G(2/\sin\theta-1) \tag{ 29-5 }$$ $$\theta = \arcsin|2\phi/\pi| \tag{ 29-6 }$$ $$Q = A^2+G \tag{ 29-6a }$$ But if $\phi = 0$ or $\pm90°$, or $\lambda = \lambda_0$, these equations are indeterminate. In that case, if $\phi=0$, $$x = R(\lambda-\lambda_0) \tag{ 29-7 }$$ and $$y = 0$$ or if $\lambda=\lambda_0$ or $\phi = \pm90^\circ$ $$x = 0$$ and $$y=\pm\pi R\tan(\theta/2) \tag{ 29-8 }$$ taking the sign of $\phi$. It may be noted that absolute values (symbol $|\thinspace|$ ) are used in several cases. The origin is at the center $(\phi = 0, \lambda = \lambda_0)$.

For the inverse equations, given $R, \lambda_0, x,$ and $y,$ to find $\phi$ and $\lambda$: Because of the complications involved, the equations are given in the order of use. This is closely based upon a recent, noniterative algorithm by Rubincam (1981): $$x = x/(\pi R) \tag{ 29-9 }$$ $$Y = y/(\pi R) \tag{ 29-10 }$$ $$c_1 = -|Y|(1+X^2+Y^2) \tag{ 29-11 }$$ $$c_2 = c_1 - 2Y^2+X^2 \tag{ 29-12 }$$ $$c_3 = -2c_1+ 1 + 2Y^2+(X^2+Y^2)^2 \tag{ 29-13 }$$ $$d = Y^2/c_3 + (2c_2^3/c_3^3-9c_1c_2/c_3^2)/27 \tag{ 29-14 }$$ $$a_1 = (c_1-c_2^3/3c_3)/c_3 \tag{ 29-15 }$$ $$m_1 = 2(-a_1/3)^{1/2} \tag{ 29-16 }$$ $$\theta_1 = (1/3)\arccos(3d/a_1m_1) \tag{ 29-17 }$$ $$\phi = \pm\pi[-m_1\cos(\theta_1+\pi/3)-c_2/3c_3] \tag{ 29-18 }$$ taking the sign of $y$. $$\lambda = \pi\{X^2+Y^2-1+[1+2(X^2-Y^2)+(X^2+Y^2)^2]^{1/2}\}/2X+\lambda_0 \tag{ 29-19 }$$ but if $X = 0$, equation (29- 19) is indeterminate. Then $$\lambda=\lambda_0 \tag{ 29-20 }$$ The formulas for scale factors are quite lengthy and are not included here. Rectangular coordinates are given in table 41 for a map of the world with unit radius of the outer circle. or $R = 1/\pi$. The longitude is measured from the central meridian. Only one quadrant of the map is given, but the map is symmetrical about both X and Y axes.

format: plain


text:
## A community for students. Sign up today

Here's the question you clicked on:

## anonymous one year ago Quadrilateral DEFG is a rectangle with vertices D(–8, 2), E(2, 7), F(5, 1), and G(–5, –4). Find the area of the rectangle. (no image, please help!!)

• This Question is Closed
1. anonymous

|dw:1439022085208:dw|

2. anonymous

oh gosh.. Do i multiply 7 by 5?

3. anonymous

Nope. think of the width of the rectangle as x, and the length as y. |dw:1439022173641:dw|

4. anonymous

ahh so many numbers

5. anonymous

Counting up from 2 $$rightarrow$$ to 7, or even from -4 $$\rightarrow$$ to 2, how many steps is that?

6. anonymous

5?

7. anonymous

|dw:1439023205596:dw| We can use the distance formula to find the distances of x and y. $x=\sqrt{(2-(-8))^2+(7-2)^2}$$y=\sqrt{(2-5)^2+(7-1)^2}$ After finding x and y, just multiply them together. $A=x\cdot y$

8. anonymous

so what was the answer?

#### Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy


text:
Free Version
Moderate

Carnosine Synthesis

BIOCHM-Z1GBPE

A number of sports nutrition companies add $\beta$-Alanine to their supplements as a way to increase the overall concentration of carnosine in the muscles to reduce fatigue during strenuous exercise.

Carnosine has a number of biological benefits as well, but it suffers a short half-life in the body.

The schematic below showcases the synthesis of carnosine.

Based on the schematic, structure A must be

, which would make structure B

.

The incorporation of structure A would result in structure C being

.


text:
# microstructpy.meshing.RasterMesh¶

class microstructpy.meshing.RasterMesh(points, elements, element_attributes=None, facets=None, facet_attributes=None)[source]

Raster mesh.

The RasterMesh class contains the points and elements in a raster mesh, also called an regular grid.

The points attribute is an Nx2 or Nx3 list of points in the mesh. The elements attribute contains the Nx4 or Nx8 list of the points at the corners of each pixel/voxel. A list of facets can also be included, though it is optional and does not need to include every facet in the mesh. Attributes can also be assigned to the elements and facets, though they are also optional.

Parameters
• points (list, numpy.ndarray) – List of coordinates in the mesh.

• elements (list, numpy.ndarray) – List of indices of the points at the corners of each element. The shape should be Nx3 in 2D or Nx4 in 3D.

• element_attributes (list, numpy.ndarray) – (optional) A number associated with each element. Defaults to None.

• facets (list, numpy.ndarray) – (optional) A list of facets in the mesh. The shape should be Nx2 in 2D or Nx3 in 3D. Defaults to None.

• facet_attributes (list, numpy.ndarray) – (optional) A number associated with each facet. Defaults to None.

as_array(element_attributes=True)[source]

numpy.ndarray containing element attributes.

Array contains -1 where there are no elements (e.g. circular domains).

Parameters

element_attributes (bool) – (optional) Flag to return element attributes in the array. Set to True return attributes and set to False to return element indices. Defaults to True.

Returns

Array of values of element atttributes, or indices.

Return type

numpy.ndarray

classmethod from_file(filename)

Read TriMesh from file.

This function reads in a triangular mesh from a file and creates an instance from that file. Currently the only supported file type is the output from write() with the format='str' option.

Parameters

filename (str) – Name of file to read from.

Returns

An instance of the class.

Return type

TriMesh

classmethod from_polymesh(polymesh, mesh_size, phases=None)[source]

Create RasterMesh from PolyMesh.

This constuctor creates a raster mesh from a polygon mesh (PolyMesh). Polygons of the same seed number are merged and the element attribute is set to the seed number it is within. The facets between seeds are saved to the mesh and the index of the facet is stored in the facet attributes.

Since the PolyMesh can include phase numbers for each region, additional information about the phases can be included as an input. The “phases” input should be a list of material phase dictionaries, formatted according to the Phase Dictionaries guide.

The mesh_size option determines the side length of each pixel/voxel. Element attributes are sampled at the center of each pixel/voxel. If an edge of a domain is not an integer multiple of the mesh_size, it will be clipped. For example, if mesh_size is 3 and an edge has bounds [0, 11], the sides of the pixels will be at 0, 3, 6, and 9 while the centers of the pixels will be at 1.5, 4.5, 7.5.

The phase type option can take one of several values, described below.

• crystalline: granular, solid

• amorphous: glass, matrix

• void: crack, hole

The crystalline option creates a mesh where cells of the same seed number are merged, but cells are not merged across seeds. _This is the default material type._

The amorphous option creates a mesh where cells of the same phase number are merged to create an amorphous region in the mesh.

Finally, the void option will merge neighboring void cells and treat them as holes in the mesh.

Parameters
• polymesh (PolyMesh) – A polygon/polyhedron mesh.

• mesh_size (float) – The side length of each pixel/voxel.

• phases (list) – (optional) A list of dictionaries containing options for each phase. Default is {'material_type': 'solid', 'max_volume': float('inf')}.

plot(index_by='element', material=[], loc=0, **kwargs)[source]

Plot the mesh.

This method plots the mesh using matplotlib. In 2D, this creates a matplotlib.collections.PolyCollection and adds it to the current axes. In 3D, it creates a mpl_toolkits.mplot3d.axes3d.Axes3D.voxels() and adds it to the current axes. The keyword arguments are passed though to matplotlib.

Parameters
• index_by (str) – (optional) {‘element’ | ‘attribute’} Flag for indexing into the other arrays passed into the function. For example, plot(index_by='attribute', color=['blue', 'red']) will plot the elements with element_attribute equal to 0 in blue, and elements with element_attribute equal to 1 in red. Defaults to ‘element’.

• material (list) – (optional) Names of material phases. One entry per material phase (the index_by argument is ignored). If this argument is set, a legend is added to the plot with one entry per material. Note that the element_attributes must be the material numbers for the legend to be formatted properly.

• loc (int or str) – (optional) The location of the legend, if ‘material’ is specified. This argument is passed directly through to matplotlib.pyplot.legend(). Defaults to 0, which is ‘best’ in matplotlib.

• **kwargs – Keyword arguments that are passed through to matplotlib.

write(filename, format='txt', seeds=None, polymesh=None)[source]

Write mesh to file.

This function writes the contents of the mesh to a file. The format options are ‘abaqus’, ‘txt’, and ‘vtk’. See the Triangular Mesh section of the Output File Formats guide for more details on these formats.

Parameters
• filename (str) – The name of the file to write.

• format (str) – {‘abaqus’ | ‘txt’ | ‘vtk’} (optional) The format of the output file. Default is ‘txt’.

• seeds (SeedList) – (optional) List of seeds. If given, VTK files will also include the phase number of of each element in the mesh. This assumes the element_attributes field contains the seed number of each element.

• polymesh (PolyMesh) – (optional) Polygonal mesh used for generating the raster mesh. If given, will add surface unions to Abaqus files - for easier specification of boundary conditions.

property mesh_size

Side length of elements.


text:
# A problem on Relative acceleration.

1. Mar 27, 2015

### Satvik Pandey

1. The problem statement, all variables and given/known data
A rocket is moving in a gravity free space with a constant acceleration of 2m/s2 along +x direction. The length of chamber inside the rocket is 4m. A ball is thrown from the left end of the chamber in +x direction with a speed of 0.3m/s relative to rocket. At the same time, another ball is thrown in the -x direction with the speed of 0.2m/s from the right end of the rocket relative to the rocket. Find the tims in seconds when the two balls hit each other.

2. Relevant equations

3. The attempt at a solution

According to my book the answer is 2 seconds. I am pretty much convinced by the solution of this question given but I am unable to find mistakes in my approach.

I tried to find $a_{ba}$
$a_{r}=2$ ($a_{r}$ is the acceleration of the rocket)
So $a_{br}=-2$
and $a_{ar}=-2$

Also $a_{br}=-2=a_{b}-a_{r}$........(1) (a_{br} is the acceleration of B wrt rocket)

and $a_{ar}=-2=a_{a}-a_{r}$...............(2)

On subtracting eq(2) from eq(1) we get

$a_b-a_a=0$ So $a_{ba} =0$

As the acceleration is constant so

$s_{relative}=u_{relative}t+0.5a_{relative}t^{2}$

Here $u_{relative}=0.5$

As acceleration is zero so I got
$t=\frac{4}{0.5}=8 sec.$

What am I doing wrong?

2. Mar 27, 2015

### Orodruin

Staff Emeritus
Assuming the balls do not hit the back of the rocket as the rocket is accelerating and the balls not, you are correct. The difference in velocities is 0.5 m/s and the gap to close is 4 m.

3. Mar 27, 2015

### Satvik Pandey

Thanks for the help.
If we don't make such assumption then the ball A will collide with the back of rocket and during the whole motion it's acceleration relative to rocket will not always remain -2 m/s2. As acceleration would not be constant so we can not use the formula mentioned in #post1. Am I correct?

4. Mar 27, 2015

### Orodruin

Staff Emeritus
Correct, but you would also need to know what happens in the bounce (ie, elastic/inelastic).

5. Mar 27, 2015

### Satvik Pandey

But it is not mentioned in the question.
In my book's solution the distance traveled by the ball B is neglected. And the answer is found by finding the time for A to travel 4m relative to the rocket. This question appeared in the engineering entrance of India and one of the option was 8 seconds also.

6. Mar 27, 2015

### Orodruin

Staff Emeritus
Well, with the problem statement as presented, 8 s would be the correct answer in my opinion.

7. Mar 27, 2015

### Satvik Pandey

But the acceleration is not constant so we can not use the formula $s=ut+0.5t^{2}$. Then,why is it correct?

8. Mar 27, 2015

### Orodruin

Staff Emeritus
Why would acceleration not be constant? The acceleration of the rocket was 2 m/s2, right? Anyway, this does not matter at all, just study the problem from the instantaneous rest frame of the rocket at the time when the balls are thrown and you do not need to care one bit about the acceleration.

9. Mar 27, 2015

### Satvik Pandey

I am talking about the acceleration of of ball B wrt A. According to given value, the ball A will collide with the back of the rocket before colliding with the ball B. When it will collide with the back of the rocket then it's velocity would be change from -0.3m/s to $+xm/s$ (relative to rocket). As the coefficient of restitution is not given so we can not find the final velocity of the ball after collision. And this would give some +ve acceleration. So, it is clear that the acceleration of the ball A is not constant wrt rocket. So acceleration of B relative A would not be constant either.

10. Mar 27, 2015

### Staff: Mentor

The ball on the left is going to have to bounce. Otherwise, it is going to go right through the left wall (as will the ball on the right). You probably need to assume that the collisions are elastic, or the problem can't be solved. I solved the problem this way, and got an answer very close to 2 seconds.

Chet

11. Mar 27, 2015

### ehild

The problem is the same when you throw a ball up with 3 m/s velocity from the ground, an an other one with 2 m/s with velocity downward from 4 m height, along the same vertical. At what height they meet? As the gravitational acceleration is the same, it will cancel. Only the relative velocity counts, which is 5 m/s.

Edit: sorry, the velocities are 0.3 m/s and 0.2 m/s, and the relative velocity 0.5 m/s.

Last edited: Mar 27, 2015
12. Mar 27, 2015

### Orodruin

Staff Emeritus
Well, if the ball is thrown inside the rocket, yes. If the collision is assumed completely inelastic (or the ball will bounce several times, it is a mess), then you would have the question when B collides with the back of the rocket. The result 2 s can only be obtained if you compute the time it would take a ball released at B with relative velocity 0 to reach the back of the rocket.

13. Mar 27, 2015

### Satvik Pandey

Thanks for the help. I got that.

I also thought like that. But initially, while solving the problem I didn't notice that A would collide with base before colliding with the ball B.

14. Mar 27, 2015

### Orodruin

Staff Emeritus
I still think the problem is not very well defined. There is nothing about the coefficient of restitution or anything hinting to whether or not the ball is actually hitting the back (or if there is a hole in the rocket to let it out, etc).

15. Mar 27, 2015

### Satvik Pandey

I too think that. The main problem is that this appeared in one of the most competitive exams of India. Now I wonder how many people have marked the wrong option.

16. Mar 27, 2015

### Orodruin

Staff Emeritus
Well ... "wrong" would seem to be ambiguous here. Perhaps someone should fire the people responsible for creating the exam - they do not seem overly competitive ...

17. Mar 27, 2015

### Staff: Mentor

I got ~1.9 seconds after 6 elastic bounces. If one assumes inelastic bounces, the time is not much different from this. This is because the left ball never gets more than about 0.03 m from the left wall, whether or not it collides elastically.

Chet

Last edited: Mar 27, 2015
18. Mar 27, 2015

### Orodruin

Staff Emeritus
The point is that you can never get 2 s regardless of how the ball bounces. This is the time it takes for the ball from B to reach the end of the rocket if it is thrown with 0 velocity.

19. Mar 27, 2015

### ehild

Neither did I


text:
# C# To Callback or not to callback

## Recommended Posts

I've got a problem and I'm not happy with the solution I found, looking for input.

Commands, which serve as passable functions are stored into a queue that gets pulled from on regular intervals. Then they are stored in an EnquedCommand object and placed into a different queue. EnquedCommand contains some info such as where the command is being run from. The second queue is also pulled from on regular intervals. The objects that submit the commands and each Queue are kept separate so they have no easy means of communication. This has worked fine so far.

The problem is I now have a command that is supposed to have the original object that enqued it do something when that command is run in the final queue. But it has no easy means of knowing when that happens.

The solution I found is to embed a callback parameter into EnquedCommand and have that passed through the queues so that the callback is called when the command is run. What I don't like about the solution is that this requires a fair bit of refactoring and, so far, this is the only command that needs one. Seems like overkill.

Are there any other solutions anyone can think of?

##### Share on other sites

callback seems fine for this.

or just in the command that needs it, have an additional member variable such as m_command_has_executed with a get_has_command_executed() member function.  Have the original object that created the command maintain a reference to the command.  On the next tick when the object runs its update() method, have it check the last_enqueued_command->get_has_command_executed() to see if it already ran.  but don't see how that is really any much better than a callback function.  just another way.

##### Share on other sites

Seems like there are some other potential concerns, such as object lifetimes. Some languages and tools are better suited at this than others, but there are important details like making sure the objects involved are all still valid when commands are run.

I've worked with container-style systems where objects in the container can have their function called at specific future points in time, such as before/after processing, before/after rendering, before/after physics. It is more special purpose than you described, but has the benefit of letting the container verify the object is still alive before calling the function.

I've also seen many event bus systems allow for delayed events to be broadcast. A system can register an event listener and fire a timed event.  If the target object is still alive the object's listener can respond, if the object has died it will have been de-registered as a listener so no problems from running a callback on dead objects.

For the specific problem you're facing a message bus sounds ideal.  The original object can indicate it needs an event with a specific unique ID.  The system can listen for the event, and if the unique ID matches it can do the work it had delayed. The system may need other protections, such as killing off long-overdue tasks, but the message bus pattern solves all kinds of inter-object communications issues.

##### Share on other sites
On 12/24/2017 at 9:10 AM, Munchkin9 said:

The solution I found is to embed a callback parameter into EnquedCommand and have that passed through the queues so that the callback is called when the command is run. What I don't like about the solution is that this requires a fair bit of refactoring

Commands are functions, right?  If they already perform work then why does anything need to be refactored?  Perform the callback within the normal work of the command's function, or wrap the command with a command which calls the original command THEN the callback, if that makes more sense.  Imagine this pattern, but adapted to whatever additional complexities you require (IPC, RPC, etc).

Action WrapAction(Action command, Action callback)
{
return () =>
{
command();
callback();
};
}

If you're dealing with IPC then you will definitely need some way of handling responses and completion which can deal with the callback.  It's not overkill.  If you're NOT dealing with IPC then do you really need all those intermediate objects and queues?

Edited by Nypyren

## Create an account

Register a new account

• 10
• 40
• 15
• 10
• 23
• ### Similar Content

• Hello,
I want to get into coding again by programming a 2D platformer to get started, but i don't know if i should use Java or C# with the unity engine.
I am pretty fit with Java, but with c# i have to start from scratch. What do you recommend and why?

• Ok, firstly, Hi.

This is my first post on this forum. I am an Indie Dev making my first game so bear with me when I say dumb stuff, I'm on a huge learning curve.

My first question is about inventory systems for unity. I am trying to make a survival type game with crafting. I have purchased Inventory manager pro by devdog from the unity asset store and it seems like a pretty powerful assett but for an intermediate coder its a little tough to use.  I'm beginning to wonder if it was the right purchase.
So my question is.... does anyone have any experience of inventory plugins / systems for unity and can anyone reccomend a system to me?
It needs to have the following: Loot system, crafting system, character sheet, blueprint system,  character stats system. Ideally with as little coding as possible.

Thanks

• I've got a bug with my brick breaker style game. The bricks move down one line at a time ever 1.5 seconds. What appears to be happening is occasionally the ball will be just about to hit the brick when the brick moves down a line, and now the ball is behind it. I'm not sure how to fix this. I have two ideas but I'm not sure of implementation. 1 solution would be to check where they were and where they are going to be before rendering the frame. Then if they crossed paths, then register the brick as hit. Solution 2 would be change how the bricks move. I could maybe slide them down line by line, instead of a jump down. I'm not sure of this will fix the issue or not. Any ideas?

• Once again Unity is frustrating me to the point of insanity.
What I am looking for is a way to find a ray intersect with the edges of the mesh, using Unity's already made collision system. I want to point out that I know how to do a line intersect, what I want to know is if Unity supports this already.

The image above shows how I sweep a ray,intersecting the mesh. The top green image shows what I want and the red shows what Unity is giving me.
I want to know if there is some way, to find the edges in Unity without creating a custom line intersection tool.
Most engines I know don't use rays for this but instead use a plane like this:

I checked the Unity "Plane intersection" but it is just a ray cast. It will still need me to find the vertices on the collision mesh to cast the ray from; if I am doing that then making my own line intersection tool is better.

I looked online and can find anything on this. Also I don't want to cut the mesh, so I don't need a way to know what side is what.
Does Unity even have collisions that support edge only detection?
• By JuliaAxt
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
public class TapController : MonoBehaviour {
public float tapForence = 10;
public float tiltSmooth = 5;
public Vector3 startPos;
Rigidbody2D Rigidbody;
Quaternion downRotation;
Quaternion forwardRotation;
private void Start() {
Rigidbody = GetComponent<Rigidbody2D>();
downRotation = Quaternion.Euler(0, 0, -90);
forwardRotation = Quaternion.Euler(0, 0, 35);

}
private void Update() {
if (Input.GetMouseButtonDown(0))
{
transform.rotation = forwardRotation;
Rigidbody.AddForce(Vector2.up * tapForce, ForceMode2D.Force);   (The name tapForcedoes not exist in current context)
}
transform.rotation = Quaternion.Lerp(transform.rotation, downRotation, tiltSmooth * Time.deltaTime);
}
}
void OnTriggerEnter2D(Collider2D col){
if (col.gameObject.tag == "scoreZone")
{
// register a score event
// play a sound
}
{
Rigidbody.simulated = false;   (Rigidbody does not contain a definition for `simulated´)
//play a sound
}
}

}


text:
Concurrency and Immutability

| Posted by Dhanji Prasanna 0 Followers on Jun 26, 2009. Estimated reading time: 5 minutes |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Concurrency is increasingly a very important aspect of modern applications. As we scale to higher levels of traffic and demand, there is a greater need for multiple concurrent threads of execution. As such, the role of objects managed by the dependency injector is extremely important. Singletons are a particularly significant example of this need.

In a large web application handling several hundreds of a requests per minute, a poorly designed singleton can be a serious bottleneck. It introduces ceilings on concurrent performance, and can even render the application unscalable under certain conditions.

Poorly concurrent behavior is also more common than you might think. And since its effects are only highlighted during performance testing, it can be difficult to identify and mitigate. So it is quite relevant for us to study the effects of concurrency on singletons.

Mutability is an essential variable in this problem. Some pitfalls are contained within the idea of immutability, too, so let's explore exactly what it means to be immutable. To change things up, we'll look at this as a series of puzzles.

Immutablity Puzzle #1

Is the following class, Book, immutable?

public class Book {
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}

This one's easy: no. The value of its title field can be changed arbitrarily by calling setTitle() so it is clearly not immutable. We can make Book immutable by declaring title final as shown below:

public class ImmutableBook {
private final String title;
public ImmutableBook(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}

Once set in the constructor, the value of title cannot change.

Immutablity Puzzle #2

Is the following class, AddressBook, immutable?

public class AddressBook {
private final String[] names;
this.names = names;
}
public String[] getNames() {
return names;
}
}

The value of the names field is set once in the constructor and is declared final. So AddressBook should be immutable, right? No! In fact, the subtle point is that since names is an array, only the reference to it is immutable by declaring it final. The following code is perfectly legal and can potentially lead to a world of hurt where multiple threads are concerned:

public class AddressBookMutator {

@Inject
this.book = book;
}

public void mutate() {
String[] names = book.getNames();

for (int i = 0; i < names.length; i++)
names[i] = "Censored!"

for (int i = 0; i < names.length; i++)
System.out.println(book.getNames()[i]);
}
}

Method mutate() destructively updates the array, even though field names is unchangeable. If you run the program it prints out "Censored!" for every name in the book. The only real solution to this problem is not to use arrays, or to use them very sparingly behind well understood safeguards and documentation. Prefer library collections (such as those found in java.util) classes where possible as these can be guarded by unmodifiable wrappers. See puzzle #3 for an illustration of using java.util.List instead of an array.

Immutablity Puzzle #3

Is the following class, BetterAddressBook, immutable?

 public class BetterAddressBook {
private final List<String> names;

this.names = Collections.unmodifiableList(names);
}
public List<String> getNames() {
return names;
}
}

Thankfully, yes, BetterAddressBook is immutable. The wrapper provided by the Collections library ensures that no updates can be made to the list once it has been set. The following code, though it compiles, results in an exception at runtime:

BetterAddressBook book = new BetterAddressBook(Arrays.asList("Landau", "Weinberg", "Hawking"));
book.getNames().add(0, "Montana");

Immutablity Puzzle #4

This is a variant on puzzle #3. Take the same BetterAddressBook class we saw earlier. Is it at all possible to construct it in such a way that I can mutate it? You are not allowed to change the code of BetterAddressBook.

The answer is quite simple, if a bit confounding:

List<String> physicists = new ArrayList<String>();
physicists.add("Einstein");

Now an iteration through BetterAddressBook's list of names:

for (String name : book.getNames())
System.out.println(name);

So, really, we must revise what we said in the answer to puzzle #3. BetterAddressBook is only immutable if its dependency list is not leaked anywhere else. Better yet, we can rewrite a completely safe version of it by copying the list at the time of its construction:

@Immutable
private final List<String> names;
this.names = Collections.unmodifiableList(new ArrayList<String>
(names));
}
public List<String> getNames() {
return names;
}
}

Now you are free to leak and mutate the original list:

List<String> physicists = new ArrayList<String>();

physicists.clear();

for (String name : book.getNames())
System.out.println(name);

Landau
Weinberg
Hawking

While it may not always be necessary to take such a cautious approach, it is advisable to copy argument lists if you are at all unsure about them escaping into other uses subsequent to construction of the immutable object.

Immutablity Puzzle #5

Is the following class, Library, immutable? (Recall Book from puzzle #1)

public class Library {
private final List<Book> books;

public Library(List<Book> books) {
this.books = Collections.unmodifiableList(new ArrayList<Book>(books));
}
public List<Book> getBooks() {
return books;
}
}

Library depends on a list of Books, but it takes care to wrap the incoming list in an unmodifiable wrapper and copies it prior to doing so. Of course, its only field is final too. Everything looks right--or does it? Actually, it turns out that Library is mutable! While the collection of books is unchangable, there is still the Book object itself. Which, as you may recall from the first puzzle, allows its title to be set:

Book book = new Book();
book.setTitle("Dependency Injection")
Library library = new Library(Arrays.asList(book));
library.getBooks().get(0).setTitle("The Tempest"); //mutates Library

The golden rule with immutability and object graphs is that every dependency of an object must also be immutable. In the case of BestAddressBook, we got lucky, since Strings in Java are already immutable. Take care to ensure that every dependency you have is safely immutable before declaring an object as such. The @Immutable annotation seen in " Immutablity Puzzle #4" helps a great deal in conveying and documenting this intent.

InfoQ readers will receive a 25% discount when ordering via manning.com. Use discount code, "infoq25".

Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Not sure if the presentation is correct

From my point of view non of this classes can't provide you immutablity guaranty if they can be subclassed.

For example a method can return a MUTABLE subclass of this "IMMUTABLE" class and the whole concept of immutability is lost.

Re: Not sure if the presentation is correct

to prove this statement just think that I will create this class extension:

private List<String> names;

super(names);

this.names = new ArrayList<String>(names);

}

public List<String> getNames() {

return names;

}

}

}

And then test it:

public class TestImmutabilityKiller {

}

public static void main(String[] args) {

System.out.println("before modification:");

}

System.out.println("after modification:");

}

}

After you test it the result will be:

before modification:

[Men at Arms, Guards! Guards!]

after modification:

[Men at Arms, Guards! Guards!, Faust - Eric]

As you can see I have been able to add a new book name into the "IMMUTABLE" BestAddressBook class

Re: Not sure if the presentation is correct

but otherwise, its quite nice article :)

Re: Not sure if the presentation is correct

to resolve this you must:

a. mark the class BestAddressBook as final or

b. mark the method BestAddressBook.getNames() as final or

c. mark the constructor of class BestAddressBook as private and use static factory method or inner static builder class for new instance creation or

d. maybe there is also some different solution

Re: Not sure if the presentation is correct

Matej's explanation of the effects of marking a class and methods as final is absolutely correct, but his "context" for making his argument (albeit just to play the devil's advocate) is just plain ugly and wrong design decision!

Why would you want to repeat the already stable base class' List<String> member "names" in a subclass? Your intention is just too wicked, or you might just lack OOP design skills. As you can see, to create your argument you are forced to use the "instanceof" operator in an if statement, which usually shows as a sign of a smelly code.

If you would really need to subclass BestAddressBook to implement an "is a" relationship, then you don't need to define "names" list again on the subclass. Making so will defeat the very essence of "structural inheritance".</string>

Re: Not sure if the presentation is correct

Your example was not able to change the BestAddressBooks' names field. What it changed was the subclass' names field. It just showed that BestAddressBook is really immutable indeed. :)

Re: Not sure if the presentation is correct

Yes, but, when you for example create a service that is doing something with the BestAddressBook you expect that the BestAdressBook is imutable and everything is fine. Fine till somebody in the future (and it is not you) decides that for his subproject he would like to extend the class with sorting functionality. He can't modify your BestAddressBook and he can't modify your cool service. So he decides that the easiest thing is to extend the BestAddressBook (in the way I have described) and as he assumes everything will work just fine. But it won't be as you have allowed him to destroy it (because you were expecting that everybody will create an execelent code). Of course you could check if the BestAddressBook you have received isn't a subclass, but from my point of view this is really not the best aproach.

Re: Not sure if the presentation is correct

The answer to the second immutability puzzle is wrong. You're defining getNames(int n) but calling getNames(). The second class *is* immutable.

Immutablity Puzzle #2 error by Mike S

In "Immutablity Puzzle #2" class AddressBook does not expose names array reference via getter so it is actually "immutable" from this article's point of view.

Re: Not sure if the presentation is correct

Although AdressBook does in fact not return the whole names array, the class is still mutable, in that the creator of an instance of an AdressBook still holds a direct reference to the names array and therefore could alter it afterwards:

String[] friends = new String[]{ "Helen", "John", "Karen", "Peter" };

fiends[1] = "Jonas";

Puzzle 3 is also mutable!

BetterAdressBook is also mutable since the creator of an instance may also keeps holding a direct reference to the List which he passed to the constructor:

List<String> friends = new ArrayList<String>();

...

friends.remove( 1 );

Re: Puzzle 3 is also mutable!

Actually this is reviewed in Puzzle #4:

So, really, we must revise what we said in the answer to puzzle #3. BetterAddressBook is only immutable if its dependency list is not leaked anywhere else.

Re: Not sure if the presentation is correct

I am not able to Compile #Puzzle4, using Eclipse 3.3 + JDK 1.6.0_12. Error is "Immutable cannot be resolved to a type". May I know which jar file I'm missing, that need to be included in the classpath, to get it compiled.

Re: Not sure if the presentation is correct

I believe it was intended to be a marker annotation that you could create on your own to denote immutability in your system. @Immutable isn't a Java API.

Re: Not sure if the presentation is correct

It is true that you modifiy names, but this is the field in your class MyBestAddressBook, it is your duty to control whether this filed is immutable. if you try to modify the field names in the super class, an exception may be thrown!

Good "follow up question based" approach of the article is helpful for interview

Thanks and keep sharing.
Close

by

on

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

16 Discuss

Login to InfoQ to interact with what matters most to you.


text:
# Word problems (Part 1) (Trigonometry)

1. 1
The sun is at an angle of elevation of 40°. A tree casts a shadow of 25m. How tall is the tree?

( Use trig ratios )
( trigonometry / trig )
2. 2
A 7m ladder leans against a wall at an angle of elevation of 35°. How high up the wall does the ladder reach?
3. 3
Emilie's tree house is 15m high. she looks at her brother Jeff at an angle of depression of 18°. How far is Jeff from the base of the tree? Good test question!
4. 4
Dennis, who is 2m tall, is standing 72m from a building. He observes that the angle of elevation to the top of the building is 30°. How high is the building? Good test question!
5. 5
Kaitlyn stands 43m from a tree. If she looks to the top of tree at an angle of 37°, find the height of the tree assuming Kaitlyn is 1.4m tall.
6. 6
A guy wire is a cable that helps stabilize a tower. If a guy wire, attached to the top of a tower makes an angle of 50° with the ground, and the tower is 45m high, how long is the guy wire?
7. 7
Ken is looking at a building that is 100m high. He is standing 68m away from the base of the building. What is the angle of elevation to the top of the building?
8. 8
If a kite string is 104m long and it is 75m above the ground, what is the angle of elevation of the string from the horizontal?
9. 9
In right triangle, $\bigtriangleup ABC$, angle C=90°, AB=19cm and AC=10cm. Find the measure of angle A.

$$e=mc^2$$


text:
# Macos – How to fix a Mac OSX Profile call to missing /usr/local/bin directory

macmacosterminaluser-profiles

Somehow, possibly in-between installing RVM and MacPorts, I get an error message whenever I open up my terminal in Snow Leopard that complains that I have an invalid identifier in my bash export. I've tracked down the culprit to be /usr/local/bin which doesn't seem to exist on my system. Should this worry me? and if not, how do I find out where /usr/local/bin is being called from?

I've looked in .profile, .bashrc, and .bash_profile in my home directory, but I can't seem to find it in any of those files. Where else could it be, or how can I easily find out?

Thanks,
Rich

Are you sure the culprit is the placement of /usr/local/bin? When Bash complains of an invalid identifier, it's complaining about the name of an exported variable, not the variable's contents (Bash does't care about the contents).
As for .profile, .bash_profile, and .bashrc, if they're not in your home directory, you can just create them.


text:
# Put a frame around all pages, except one, in a book

I am writing a book and would like to put a red, 5pt thick frame around all pages, except around one page in the middle of the book, which contains a figure that is bigger than the frame.

The frame should be placed 1cm above the upper text margin, 1cm under the bottom margin and 1.5cm from the left and right margins; it should not suround the header or the footer, which both should be just outside the frame.

I am using XeLaTeX, but have not descided if I am going to use the memoir or the KOMA-script class for the book. It might depend on this answer.

• – Claudio Fiandrino Feb 10 '13 at 17:38
• Welcome to TeX.SE. Just a remark: your figure should not exceed the printing area of the page, i.e. the text body + header + footer + margin notes area. – yo' Feb 10 '13 at 17:39
• Please read the related links on the right first. – kiss my armpit Feb 10 '13 at 17:44
• I have looked at other posts, I still can't draw a border that satisfies my specified distance from the text. I tried pgfpages, but it shrinks the text and puts the border outside the header and footer. I think tikz is what I need, but I am not sure how to make a border around all pages with it. – user25750 Feb 10 '13 at 19:52
• @tohecz I want to turn of the frame on one page. The picture is not really bigger than the printing area, I just tried to keep the question as general as possible. – user25750 Feb 10 '13 at 19:57

Here's a self-documented fully working code. You should of course set up your desired headers (fancyhdr package) and page geometry (geometry package). The code strongly relies on package fancyhdr and keeping the center head empty!

\documentclass{article}

\usepackage{fancyhdr,xcolor}

% the head clashes with the box, so we change the page geometry

\makeatletter

\fancyhf{}
% we use center head to place the box in it
\smash{% occupy no vertical space
\raise\dimexpr-\headsep-\textheight-1cm\relax% move down by text heiht + head sep + 1cm so that it sits 1cm below the text
\hbox to 0pt{% start a box occupying zero space
\color{red}% colour
\fboxsep0pt % \fbox should not add any extra spacing
\fboxrule5pt % line width
\hss\fbox{% \hss is infinitely shrinkable space
% phantom rule occupying exactly the right space:
% width of the text + 2*1.5cm
% height of the text + 2*1cm
\phantom{\rule{\dimexpr\textwidth+3cm}{\dimexpr\textheight+2cm\relax}}%
}\hss%
}%
}%
}

\pagestyle{fancy} % use the newly defined style

% new style {nofancy}
\fancypagestyle{nofancy}{
\ps@@fancy % copy the default {fancy} style
}
\makeatother

\usepackage{lipsum}

\begin{document}

\lipsum[1-20]
\thispagestyle{nofancy}
\lipsum[21-40]

\end{document}

• Very grateful for your help! However, this code fails to draw a frame around the first page of a new chapter, which has a special header/footer style. – user25750 Feb 13 '13 at 21:21
• Please edit your question and add a Minimal Working Example. Then I'll be able to modify the solution so that it suits exacttly your situation. – yo' Feb 13 '13 at 22:06

Redefining the current \fbox to use different margins allows to use the simple \fancypage command from the package fancybox

\documentclass[a4paper,DIV9]{scrartcl}
\usepackage{lipsum}
\usepackage{fancybox}
\makeatletter
\long\def\FBox#1{%
\leavevmode
\setbox\@tempboxa\hbox{%
\color@begingroup
\kern15mm{#1}\kern15mm
\color@endgroup}%
\@frameb@x\relax}
\makeatother

\fancypage{\fboxsep=1cm\fboxrule=5pt\FBox}{}

\begin{document}
\lipsum[1-20]
\thisfancypage{}{}% no frame
\lipsum[21-40]
\end{document}

• This method puts all text into a box, which influence the marigins. It might work, but I am afraid the code is too advanced for me. – user25750 Feb 13 '13 at 21:23
• @user25750: it does not influence the margins and it only redefines the current \fbox command, that's all. – user2478 Feb 14 '13 at 8:40

I experimented a bit and found a solution using the background and tikz packages. I still don't understand how the position option works in the background package - I am not sure from where to where it measures. By playing around with the parameters, I found this solution:

\usepackage[contents={},opacity=1,scale=1.5,color=red!100]{background}
\usepackage{ifthen}


text:
Reminder: in case of any technical issues, you can use the lightweight website m1.codeforces.com, m2.codeforces.com, m3.codeforces.com. ×

E. Lucky Number Representation
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

We know that lucky digits are digits 4 and 7, however Vasya's got another favorite digit 0 and he assumes it also is lucky! Lucky numbers are such non-negative integers whose decimal record only contains lucky digits. For example, numbers 0, 47, 7074 are lucky, but 1, 7377, 895,  -7 are not.

Vasya has t important positive integers he needs to remember. Vasya is quite superstitious and he wants to remember lucky numbers only, so he is asking you for each important number to represent it as a sum of exactly six lucky numbers (Vasya just can't remember more numbers). Then Vasya can just remember these six numbers and calculate the important number at any moment.

For each of t important integers represent it as the sum of six lucky numbers or state that this is impossible.

Input

The first line contains a single integer t (1 ≤ t ≤ 5000).

Next t lines contain a single positive integer ni (1 ≤ ni ≤ 1018) — the list of important numbers.

Please, do not use the %lld to read or write 64-bit integers С++. It is preferred to read the cin, cout streams or the %I64d specifier.

Output

Print t lines. The i-th line must contain the answer for the i-th important number: if the solution exists, the line must contain exactly six lucky numbers the sum of which equals ni, if the solution doesn't exist the string must contain a single integer -1.

If there are multiple answers print any of them.

Examples
Input
54217444751
Output
7 7 7 7 7 7-1400 0 40 0 4 07 0 0 0 0 047 4 0 0 0 0


text:
# Animated Heatmap with Heatmap.js

I recently saw HalifaxCrime, a hackathon project that animates crime data. I hoped to use the same technique to make a lightweight heatmap that I could feed with data from any Socrata dataset with a location column and a date & time column.

HalifaxCrime uses Heatmap.js an open source JavaScript library for making heatmaps. Most of the examples involve tracking user mouse movements and clicks on websites, but it’s also quite useful for mapping. (So useful that there are existing plugins for Google Maps, Leaflet, and OpenLayers. I started with this non-animated example from the heatmap-leaflet.js plugin page.

Basically, you feed heatmap.js an array of objects, each with x/y values and some sort of weight. The code below gets you a leaflet map with a static heatmap layer drawn in canvas. (One important config variable is useLocalExtrema, which adjusts the heatmap based on the points that are in the current view… I think this could be pretty misleading for an interactive map, so I chose to turn it off.)

To make an animated heatmap with time series data, we just need to re-draw the layer over and over again, and modify each “frame” of the animation with new data, and/or some modification of the existing data. The workflow goes like this:

1. Add data for the current time period to the map.
2. Increment the value field for each point for a few frames to give it a heat-up effect.
3. Decrement the value for each field to give it a cool-down effect.
4. When the value gets to zero, remove that point from the array.
5. Repeat for subsequent time periods, adding new data to the map while the previous data is still “cooling off”

Obviously, there are a lot of variables to tweak here, and you can yield different results. But first, let’s use jQuery’s \$getJSON() method to get some time-series vehicle collisions data from data.cityofnewyork.us.

After cleaning up the results a bit to filter out null lat/lon fields, I’m left with an array of goodData that I can start mapping.

For my heatmap experiment, I am using setInterval() to iterate every 100ms. My data is only accurate to 1 day, so I am adding 1 day’s worth of data every 10 iterations, or one day per second. Here’s the interval function minus the chart bits:

New points start with a value(weight) of 0, and I use a boolean to determine whether they are heating up or cooling down. On each interval, points that are heating up have their value incremented by .8, while those that are cooling down have their value decremented by .1. (Points arrive quickly, but fade out slowly). Once a point’s value is greater than or equal to 10, we toggle the boolean and start cooling it off.

Doing the math, a point will heat-up over 12 intervals (1.2 seconds), then cool down over 100 intervals (10 seconds). Since we are adding new data every second, there will be plenty of overlap, allowing the map to emphasize those areas where there are many events happening over a several-day period.

You can fork my repo here and tweak the config values to see what kind of results you get.


text:
Research

# A new kind of double Chebyshev polynomial approximation on unbounded domains

Ayşe Betül Koç* and Aydın Kurnaz

Author Affiliations

Department of Mathematics, Faculty of Science, Selcuk University, Konya, Turkey

For all author emails, please log on.

Boundary Value Problems 2013, 2013:10  doi:10.1186/1687-2770-2013-10

 Received: 2 October 2012 Accepted: 4 January 2013 Published: 22 January 2013

This is an Open Access article distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/2.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

### Abstract

In this study, a new solution scheme for the partial differential equations with variable coefficients defined on a large domain, especially including infinities, has been investigated. For this purpose, a spectral basis, called exponential Chebyshev (EC) polynomials, has been extended to a new kind of double Chebyshev polynomials. Many outstanding properties of those polynomials have been shown. The applicability and efficiency have been verified on an illustrative example.

MSC: 35A25.

##### Keywords:
partial differential equations; pseudospectral-collocation method; matrix method; unbounded domains

### 1 Introduction

The importance of special functions and orthogonal polynomials occupies a central position in the numerical analysis. Most common solution techniques of differential equations with these polynomials can be seen in [1-12]. One of the most important of those special functions is Chebyshev polynomials. The well-known first kind Chebyshev polynomials [1] are orthogonal with respect to the weight-function w c ( x ) = 1 1 x 2 on the interval [ 1 , 1 ] . These polynomials have many applications in different areas of interest, and a lot of studies are devoted to show the merits of them in various ways. One of the application fields of Chebyshev polynomials can appear in the solution of differential equations. For example, Chebyshev polynomial approximations have been used to solve ordinary differential equations with boundary conditions in [1], with collocation points in [13], the general class of linear differential equations in [14,15], linear-integro differential equations with collocation points in [16], the system of high-order linear differential and integral equations with variable coefficients in [17,18], and the Sturm-Liouville problems in [19].

Some of the fundamental ideas of Chebyshev polynomials in one-variable techniques have been extended and developed to multi-variable cases by the studies of Fox et al.[1], Basu [20], Doha [21] and Mason et al.[5]. In recent years, the Chebyshev matrix method for the solution of partial differential equations (PDEs) has been proposed by Kesan [22] and Akyuz-Dascioglu [23] as well.

On the other hand, all of the above studies are considered on the interval [ 1 , 1 ] in which Chebyshev polynomials are defined. Therefore, this limitation causes a failure of the Chebyshev approach in the problems that are naturally defined on larger domains, especially including infinity. Then, Guo et al.[24] has proposed a modified type of Chebyshev polynomials as an alternative to the solutions of the problems given in a nonnegative real domain. In his study, the basis functions called rational Chebyshev polynomials are orthogonal in L 2 ( 0 , ) and are defined by

R n ( x ) = T n ( x 1 x + 1 ) .

Parand et al. and Sezer et al. successfully applied spectral methods to solve problems on semi-infinite intervals [25,26]. These approaches can be identified as the methods of rational Chebyshev Tau and rational Chebyshev collocation, respectively. However, this kind of extension also fails to solve all of the problems over the whole real domain. More recently, we have introduced a new modified type of Chebyshev polynomials that is developed to handle the problems in the whole real range called exponential Chebyshev (EC) polynomials [27].

In this study, we have shown the extension of the EC polynomial method to multi-variable case, especially, to two-variable problems.

### 2 Properties of double EC polynomials

The well-known first kind Chebyshev polynomials are orthogonal in the interval [ 1 , 1 ] with respect to the weight-function w c ( x ) = 1 1 x 2 and can be simply determined with the help of the recurrence formula [1]

T 0 ( x ) = 1 , T 1 ( x ) = x , T n + 1 ( x ) = 2 x T n ( x ) T n 1 ( x ) , n 1 . (2.1)

Therefore, the exponential Chebyshev (EC) functions are recently defined in a similar fashion as follows [27].

Let

L 2 ( φ ) = { f : f L 2 = | f ( x ) | 2 w e ( x ) d x < }

be a function space with the weight function w e ( x ) = e x e x + 1 . We also assume that, for a nonnegative integer n, the nth derivative of a function f L 2 is also in L 2 . Then an EC polynomial can be given by

where y = e x 1 e x + 1 .

This definition leads to the three-term recurrence equation for EC polynomials

E 0 ( x ) = 1 , E 1 ( x ) = e x 1 e x + 1 , E n + 1 ( x ) = 2 ( e x 1 e x + 1 ) E n ( x ) E n 1 ( x ) , n 1 . (2.2)

This definition also satisfies the orthogonality condition [27]

E n ( x ) E m ( x ) w ( x ) d x = c m π 2 δ m n , (2.3)

where c m = { 2 , m = 0 , 1 , m 0 and δ m n is the Kronecker function.

#### Double EC functions

Basu [20] has given the product T r , s ( x , y ) = T r ( x ) T s ( y ) which is a form of bivariate Chebyshev polynomials. Mason et al.[5] and Doha [11] have also mentioned a Chebyshev polynomial expression for an infinitely differentiable function u ( x , y ) defined on the square S ( 1 x , y 1 ) by

u ( x , y ) r = 0 s = 0 a r s T r ( x ) T s ( y ) ,

where T r ( x ) and T s ( y ) are Chebyshev polynomials of the first kind, and the double primes indicate that the first term is 1 4 a 0 , 0 ; a m , 0 and a 0 , n are to be taken as 1 2 a m , 0 and 1 2 a 0 , n for m , n 0 , respectively.

Definition

Based on Basu’s study, now we introduce double EC polynomials in the following form:

E r , s ( x , y ) = E r ( x ) E s ( y ) , (2.4)

where E m ( x ) , E n ( y ) are EC polynomials defined by

E r ( x ) = T r ( e x 1 e x + 1 ) , E s ( y ) = T s ( e y 1 e y + 1 ) .

Recurrence relation The polynomial E r , s ( x , y ) satisfies the recurrence relations

(2.5)

(2.6)

If the function f ( x , y ) is continuous throughout the whole infinite domain < x , y < , then the E r , s ( x , y ) ’s are biorthogonal with respect to the weight function

w e ( x , y ) = e x + y ( e x + 1 ) ( e y + 1 ) , (2.7)

and we have

E i , j ( x , y ) E k , l ( x , y ) w ( x , y ) d x d y = { π 2 , i = j = k = l = 0 , π 2 4 , i = k 0 , j = l 0 , π 2 2 , i = k = 0 , j = l 0 or i = k 0 , j = l = 0 , 0 , for all other values of   i , j , k , l . (2.8)

Multiplication E i , j ( x , y ) is said to be of higher order than E m , n ( x , y ) if i + j > m + n . Then the following result holds:

(2.9)

#### Function approximation

Let u ( x , y ) be an infinitely differentiable function defined on the square S ( < x , y < ) . Then it may be expressed in the form

u ( x , y ) = r = 0 s = 0 a r , s E r , s ( x , y ) , (2.10)

where

a r , s = u ( x , y ) E r , s ( x , y ) w ( x , y ) d x d y E r , s 2 ( x , y ) w ( x , y ) d x d y . (2.11)

If u ( x , y ) in Eq. (2.10) is truncated up to the mth and nth terms, then it can be written in the matrix form

u ( x , y ) r = 0 m s = 0 n a r , s E r , s ( x , y ) = E ( x , y ) A (2.12)

with E ( x , y ) is a 1 × ( m + 1 ) ( n + 1 ) EC polynomial matrix with entries E r , s ( x , y ) ,

E ( x , y ) = [ E 0 , 0 ( x , y ) E 0 , 1 ( x , y ) E 0 , n ( x , y ) E 1 , 0 ( x , y ) E 1 , 1 ( x , y ) E 1 , n ( x , y ) E m , 0 ( x , y ) E m , 1 ( x , y ) E m , n ( x , y ) ] (2.13)

and A is an unknown coefficient vector,

A = [ a 0 , 0 a 0 , 1 a 0 , n a 1 , 0 a 1 , 1 a 1 , n a m , 0 a m , 1 a m , n ] T . (2.14)

#### Matrix relations of the derivatives of a function

( i + j ) th-order partial derivative of u ( x , y ) can be written as

u ( i , j ) ( x , y ) r = 0 m s = 0 n a r , s E r , s ( i , j ) ( x , y ) (2.15)

and its matrix form is

u ( i , j ) ( x , y ) E ( i , j ) ( x , y ) A , (2.16)

where E r , s ( 0 , 0 ) = E r , s , u ( 0 , 0 ) ( x , y ) = u ( x , y ) and

E ( i , j ) ( x , y ) = [ E 0 , 0 ( i , j ) ( x , y ) E 0 , 1 ( i , j ) ( x , y ) E 0 , n ( i , j ) ( x , y ) E 1 , 0 ( i , j ) ( x , y ) E 1 , n ( i , j ) ( x , y ) E m , 0 ( i , j ) ( x , y ) E m , 1 ( i , j ) ( x , y ) E m , n ( i , j ) ( x , y ) ] .

Proposition 1Let u ( x , y ) and ( i , j ) th-order derivative be given by (2.12) and (2.16), respectively. Then there exists a relation between the double EC coefficient row vector E ( x , y ) and ( i + j ) th-order partial derivatives of the vector E ( i , j ) ( x , y ) of size 1 × ( m + 1 ) ( n + 1 ) as

E ( i , j ) ( x , y ) = E ( x , y ) ( D x ) i ( D y ) j , (2.17)

where D x and D y are ( m + 1 ) ( n + 1 ) × ( m + 1 ) ( n + 1 ) operational matrices for partial derivatives given in the following forms:

D x = [ c α , β ] T = ( diag ( α 4 I , O , α 4 I ) ) T , α = 0 , 1 , , m , β = 0 , 1 , , n

and

Here, IandOare ( m + 1 ) ( n + 1 ) identity and zero matrices, respectively, andTdenotes the usual matrix transpose.

Proof Taking the partial derivatives of E 0 , s , E 1 , s and both sides of the recurrence relation (2.5) with respect to x, we get

(2.18)

(2.19)

and

E r + 1 , s ( 1 , 0 ) ( x , y ) = x [ 2 E 1 , s ( 0 , 0 ) ( x , y ) E r , s ( 0 , 0 ) ( x , y ) E r 1 , s ( 0 , 0 ) ( x , y ) ] = 2 E 1 , s ( 1 , 0 ) ( x , y ) E r , s ( 0 , 0 ) ( x , y ) + 2 E 1 , s ( 0 , 0 ) ( x , y ) E r , s ( 1 , 0 ) ( x , y ) E r 1 , s ( 1 , 0 ) ( x , y ) , s 0 . (2.20)

By using the relations (2.18)-(2.20) for r = 0 , 1 , 2 , , m the elements c α , β of the matrix of partial derivatives D x can be obtained from the following equalities:

{ E 0 , s ( 1 , 0 ) ( x , y ) = 0 , E 1 , s ( 1 , 0 ) ( x , y ) = 1 4 E 0 , s ( 0 , 0 ) ( x , y ) 1 4 E 2 , s ( 0 , 0 ) ( x , y ) , E 2 , s ( 1 , 0 ) ( x , y ) = 1 2 E 1 , s ( 0 , 0 ) ( x , y ) 1 2 E 3 , s ( 0 , 0 ) ( x , y ) , E m , s ( 1 , 0 ) ( x , y ) = m 4 E m 1 , s ( 0 , 0 ) ( x , y ) m 4 E m + 1 , s ( 0 , 0 ) ( x , y ) , s 0 . (2.21)

Similarly, taking the partial derivatives of E r , 0 , E r , 1 and both sides of the recurrence relation (2.6) with respect to y, respectively, we write

(2.22)

(2.23)

and

E r , s + 1 ( 0 , 1 ) ( x , y ) = x [ 2 E r , 1 ( 0 , 0 ) ( x , y ) E r , s ( 0 , 0 ) ( x , y ) E r , s 1 ( 0 , 0 ) ( x , y ) ] = 2 E r , 1 ( 0 , 1 ) ( x , y ) E r , s ( 0 , 0 ) ( x , y ) + 2 E r , 1 ( 0 , 0 ) ( x , y ) E r , s ( 0 , 1 ) ( x , y ) E r , s 1 ( 0 , 1 ) ( x , y ) , r 0 . (2.24)

Then with the help of the relations (2.22)-(2.24), the elements d α , β of the matrices of partial derivatives D y can be obtained from

{ E r , 0 ( 0 , 1 ) ( x , y ) = 0 , E r , 1 ( 0 , 1 ) ( x , y ) = 1 4 E r , 0 ( 0 , 0 ) ( x , y ) 1 4 E r , 2 ( 0 , 0 ) ( x , y ) , E r , n ( 0 , 1 ) ( x , y ) = n 4 E r , n 1 ( 0 , 0 ) ( x , y ) n 4 E r , n + 1 ( 0 , 0 ) ( x , y ) , r 0 . (2.25)

We have noted here that E r , s ( 1 , 0 ) ( x , y ) = E r , s ( 0 , 0 ) ( x , y ) = 0 for r > m and E r , s ( 0 , 1 ) ( x , y ) = E r , s ( 0 , 0 ) ( x , y ) = 0 for s > n .

From (2.21) and (2.25), the following equalities hold for i = 0 , 1 , 2 , and j = 0 , 1 , 2 ,

E ( 1 , 0 ) ( x , y ) = E ( x , y ) D x , E ( 2 , 0 ) ( x , y ) = E ( 1 , 0 ) ( x , y ) D x = ( E ( x , y ) D x ) D x = E ( x , y ) ( D x ) 2 , E ( i , 0 ) ( x , y ) = E ( i 1 , 0 ) ( x , y ) D x = E ( x , y ) ( D x ) i (2.26)

and

E ( 0 , 1 ) ( x , y ) = E ( x , y ) D y , E ( 0 , 2 ) ( x , y ) = E ( 0 , 1 ) ( x , y ) D y = ( E ( x , y ) D y ) D y = E ( x , y ) ( D y ) 2 , E ( 0 , j ) ( x , y ) = E ( 0 , j 1 ) ( x , y ) D y = E ( x , y ) ( D y ) j , (2.27)

where E ( 0 , 0 ) ( x , y ) = E ( x , y ) and ( D x ) 0 = ( D y ) 0 = I and I denotes ( m + 1 ) ( n + 1 ) identity matrix.

Then utilizing the equalities in (2.26) and (2.27), the explicit relation between the double EC polynomial row vector and those of its derivatives has been proved as follows:

E ( i , j ) ( x , y ) = E ( i , 0 ) ( x , y ) ( D y T ) j = ( E ( 0 , 0 ) ( x , y ) ( D x ) i ) ( D y ) j = E ( x , y ) ( D x ) i ( D y ) j

or

E ( i , j ) ( x , y ) = E ( 0 , j ) ( x , y ) ( D x T ) i = ( E ( 0 , 0 ) ( x , y ) ( D y ) j ) ( D x T ) i = E ( x , y ) ( D y ) j ( D x ) i .

□

Remark ( D x ) i ( D y ) j = ( D y ) j ( D x ) i .

CorollaryFrom Eqs. (2.16) and (2.17), it is clear that the derivatives of the function are expressed in terms of double EC coefficients as follows:

u ( i , j ) ( x , y ) = E ( x , y ) ( D x ) i ( D y ) j A . (2.28)

### 3 Collocation method with double EC polynomials

In the process of obtaining the numerical solutions of partial differential equations with the double EC method, the main idea or major step is to evaluate the necessary Chebyshev coefficients of the unknown function. So, in Section 2, we give the explicit relations between the polynomials E r , s ( x , y ) of an unknown function and those of its derivatives E r , s ( i , j ) ( x , y ) for different nonnegative integer values of i and j.

In this section, we consider the higher-order linear PDE with variable coefficients of a general form

i = 0 p j = 0 r q i , j ( x , y ) u ( i , j ) ( x , y ) = f ( x , y ) , < x , y < (3.1)

with the conditions mentioned in [23] as three possible cases:

t = 1 ρ i = 0 p j = 0 r b t i , j u ( i , j ) ( ω t , η t ) = λ (3.2)

and/or

t = 1 υ i = 0 p j = 0 r c t i , j ( x ) u ( i , j ) ( x , γ t ) = g ( x ) (3.3)

and/or

t = 1 ϑ i = 0 p j = 0 r d t i , j ( y ) u ( i , j ) ( ε t , y ) = h ( y ) . (3.4)

Here, u ( 0 , 0 ) ( x , y ) = u ( x , y ) , u ( i , j ) ( x , y ) = i + j x i y j u ( x , y ) and q i , j ( x , y ) , f ( x , y ) , c t i , j ( x ) , g ( x ) , d t i , j ( y ) , h ( y ) are known functions on the square S ( < x , y < ) . We now describe an approximate solution of this problem by means of double EC series as defined in (2.10). Our aim is to find the EC coefficients in the vector A. For this reason, we can represent the given problem and its conditions by a system of linear algebraic equations by using collocation points.

Now, the collocation points can be determined in the inner domain as

x k = ln ( 1 + cos ( k π / m ) 1 cos ( k π / m ) ) , y l = ln ( 1 + cos ( l π / n ) 1 cos ( l π / n ) ) ( k = 1 , 2 , , m 1 ; l = 1 , 2 , , n 1 ) (3.5)

and at the boundaries

(i) x m and y n ,

(ii) x 0 and y n .

Since EC polynomials are convergent at both boundaries, namely their values are either 1 or −1, the appearance of infinity in the collocation points does not cause a loss in the method.

Therefore, when we substitute the collocation points into the problem (3.1), we get

i = 0 p j = 0 r q i , j ( x k , y l ) u ( i , j ) ( x k , y l ) = f ( x k , y l ) ( k = 0 , 1 , , m , l = 0 , 1 , , n ) . (3.6)

The system (3.6) can be written in the matrix form as follows:

i = 0 p j = 0 r Q i , j U ( i , j ) = F , p m , r n , (3.7)

where Q i , j denotes the diagonal matrix with the elements q i , j ( x k , y l ) ( k = 0 , 1 , , m ; l = 0 , 1 , , n ) and F denotes the column matrix with the elements f ( x k , y l ) ( k = 0 , 1 , , m ; l = 0 , 1 , , n ).

Putting the collocation points into derivatives of the unknown function as in Eq. (2.28) yields

[ u ( i , j ) ( x k , y l ) ] = E ( x k , y l ) ( D x ) i ( D y ) j A , U ( i , j ) = [ u ( i , j ) ( x 0 , y 0 ) u ( i , j ) ( x 0 , y n ) u ( i , j ) ( x 1 , y 0 ) u ( i , j ) ( x 1 , y n ) u ( i , j ) ( x m , y n ) ] = E ( i , j ) A = E ( D x ) i ( D y ) j A , (3.8)

where E is the block matrix given by

E = [ E ( x 0 , y 0 ) E ( x 0 , y 1 ) E ( x 0 , y n ) E ( x 1 , y 0 ) E ( x 1 , y 1 ) E ( x 1 , y n ) E ( x m , y 0 ) E ( x m , y 1 ) E ( x m , y n ) ] T

and for i = j = 0 , we see

U = E A . (3.9)

Therefore, from Eq. (3.7), we get a system of the matrix equation for the PDE

( i = 0 p j = 0 r Q i , j E ( D x ) i ( D y ) j ) A = F , (3.10)

which corresponds to a system of ( m + 1 ) ( n + 1 ) linear algebraic equations with unknown double EC coefficients a r , s .

It is also noted that the structures of matrices Q i , j and F vary according to the number of collocation points and the structure of the problem. However, E, D x and D y do not change their nature for fixed values of m and n which are truncation limits of the EC series. In other words, the changes in E, D x and D y are just dependent on the number of collocation points.

Briefly, we can denote the expression in the parenthesis of (3.10) by W and write

W A = F . (3.11)

Then the augmented matrix of Eq. (3.11) becomes

[ W : F ] . (3.12)

Applying the same procedure for the given conditions (3.2)-(3.4), we have

(3.13)

(3.14)

(3.15)

Then these can be written in a compact form

V A = R , (3.16)

where V is an h × ( m + 1 ) ( n + 1 ) matrix and R is an h × 1 matrix, so that h is the rank of all row matrices belonging to the given condition. The augmented matrices of the conditions become

[ V : R ] . (3.17)

Consequently, (3.12) together with (3.17) can be written in a new augmented matrix form

[ W : F ] . (3.18)

This form can be achieved by replacing some rows of (3.12) by the rows of (3.17) accordingly, or adding those rows to the matrix (3.12) provided that ( det W ) 0 . Then it can be written in the following compact form:

W A = F . (3.19)

Finally, the vector A (thereby the coefficients a r , s ) is determined by applying some numerical methods (e.g., Gauss elimination) designed especially to solve the system of linear equations. Therefore, the approximate solution can be obtained. In other words, it gives the double EC series solution of the problem (3.1) with given conditions.

### 4 Illustration

Now, we give an example to show the ability and efficiency of the double EC polynomial approximation method.

Example

Let us consider the linear partial differential equation

u x y 2 e x + 1 u y = 4 e y ( e x + 1 ) 2 ( e y + 1 ) 2

with the conditions

u y ( 0 , y ) = 0 , u ( x , 0 ) = 0 .

It is known that the exact solution of the problem is u ( x , y ) = e x + y e x e y + 1 ( e x + 1 ) ( e y + 1 ) .

Absolute errors of the proposed procedure at the grid points are tabulated for m = n = 15 in Table 1.

Table 1. Absolute errors of Example at different points

Contour plots of the exact solutions and the approximate solutions are given for the region 2 x , y 10 in (a) and (b) and for the region 3 x 3 , 5 y 5 in (c) and (d) of Figure 1, respectively. Figure 2 shows a graphical representation of the exact solution and, for m = n = 15 , the approximate solution of the example.

Figure 1. Contour plots of exact and approximate solutions.

Figure 2. Exact and approximate solution of the example.

### 5 Conclusion

In this article, a new solution scheme for the partial differential equation with variable coefficients defined on unbounded domains has been investigated and EC polynomials have been extended to double EC polynomials to solve multi-variable problems. It is also noted that the double EC-collocation method is very effective and has a direct ability to solve multi-variable (especially two-variable) problems in the infinite domain. For computational purposes, this approach also avoids more computations by using sparse operational matrices and saves much memory. On the other hand, the double EC polynomial approach deals directly with infinite boundaries, and their operational matrices are of few non-zero entries lain along two subdiagonals.

### Competing interests

The authors declare that they have no competing interests.

### Authors’ contributions

ABK wrote the first draft and AK corrected and improved the final version. All authors read and approved the final draft.

### Acknowledgements

This study was supported by the Research Projects Center (BAP) of Selcuk University. The authors would like to thank the editor and referees for their valuable comments and remarks which led to a great improvement of the article. Also, ABK and AK would like to thank the Selcuk University and TUBITAK for their support. We note here that this study was presented orally at the International Conference on Applied Analysis and Algebra (ICAAA 2012), Istanbul, 20-24 June, (2012).

### References

1. Fox, L, Parker, IB: Chebyshev Polynomials in Numerical Analysis, Oxford University Press, London (1968) [Revised 2nd edition,1972]

2. Lebedev, NN: Special Functions and Their Applications, Prentice Hall, London (1965) [Revised Eng. Ed.: Translated and Edited by Silverman, RA (1972)]

3. Yudell, LL: The special functions and their approximations V-2. In: Bellman R (ed.) Mathematics in Science and Engineering, Academic Press, New York (1969)

4. Wang, ZX, Guo, DR: Special Functions, World Scientific, Singapore (1989)

5. Mason, JC, Handscomb, DC: Chebyshev Polynomials, CRC Press, Boca Raton (2003)

6. Marcellan F, Assche WV (eds.): Orthogonal Polynomials and Special Functions: Computation and Applications, Springer, Heidelberg (2006)

7. Mathai, AM, Haubold, HJ: Special Functions for Applied Scientists, Springer, New York (2008)

8. Agarwal, RP, O’Regan, D: Ordinary and Partial Differential Equations with Special Functions Fourier Series and Boundary Value Problems, Springer, New York (2009)

9. Schwartz, AL: Partial differential equations and bivariate orthogonal polynomials. J. Symb. Comput.. 28, 827–845 Article ID Jsco.1999.0342 (1999)

Article ID Jsco.1999.0342

Publisher Full Text

10. Makukula, ZG, Sibanda, P, Motsa, SS: A note on the solution of the Von Karman equations using series and Chebyshev spectral methods. Bound. Value Probl.. 2010, Article ID 471793 (2010)

11. Doha, EH, Bhrawy, AH, Saker, MA: On the derivatives of Bernstein polynomials: an application for the solution of high even-order differential equations. Bound. Value Probl.. 2011, Article ID 829543 (2011)

12. Xu, Y: Orthogonal polynomials and expansions for a family of weight functions in two variables. Constr. Approx.. 36, 161–190 (2012). Publisher Full Text

13. Wright, K: Chebyshev collocation methods for ordinary differential equations. Comput. J.. 6(4), 358–365 (1964). Publisher Full Text

14. Scraton, RE: The solution of linear differential equations in Chebyshev series. Comput. J.. 8(1), 57–61 (1965). Publisher Full Text

15. Sezer, M, Kaynak, M: Chebyshev polynomial solutions of linear differential equations. Int. J. Math. Educ. Sci. Technol.. 27(4), 607–618 (1996). Publisher Full Text

16. Akyüz, A, Sezer, M: A Chebyshev collocation method for the solution of linear integro-differential equations. Int. J. Comput. Math.. 72, 491–507 (1999). Publisher Full Text

17. Akyüz, A, Sezer, M: Chebyshev polynomial solutions of systems of high-order linear differential equations with variable coefficients. Appl. Math. Comput.. 144, 237–247 (2003). Publisher Full Text

18. Akyüz-Daşcıoğlu, A: Chebyshev polynomial solutions of systems of linear integral equations. Appl. Math. Comput.. 151, 221–232 (2004). Publisher Full Text

19. Celik, I, Gokmen, G: Approximate solution of periodic Sturm-Liouville problems with Chebyshev collocation method. Appl. Math. Comput.. 170(1), 285–295 (2005). Publisher Full Text

20. Basu, NK: On double Chebyshev series approximation. SIAM J. Numer. Anal.. 10(3), 496–505 (1973). Publisher Full Text

21. Doha, EH: The Chebyshev coefficients of the general order derivative of an infinitely differentiable function in two or three variables. Ann. Univ. Sci. Bp. Rolando Eötvös Nomin., Sect. Comput.. 13, 83–91 (1992)

22. Kesan, C: Chebyshev polynomial solutions of second-order linear partial differential equations. Appl. Math. Comput.. 134, 109–124 (2003). Publisher Full Text

23. Akyüz-Daşcıoğlu, A: Chebyshev polynomial approximation for high-order partial differential equations with complicated conditions. Numer. Methods Partial Differ. Equ.. 25, 610–621 (2009). Publisher Full Text

24. Guo, B, Shen, J, Wang, Z: Chebyshev rational spectral and pseudospectral methods on a semi-infinite interval. Int. J. Numer. Methods Eng.. 53, 65–84 (2002). Publisher Full Text

25. Parand, K, Razzaghi, M: Rational Chebyshev Tau method for solving higher-order ordinary differential equations. Int. J. Comput. Math.. 81, 73–80 (2004)

26. Sezer, M, Gülsu, M, Tanay, B: Rational Chebyshev collocation method for solving higher-order linear differential equations. Numer. Methods Partial Differ. Equ.. 27(5), 1130–1142 (2011). Publisher Full Text

27. Kaya, B, Kurnaz, A, Koc, AB: Exponential Chebyshev polynomials. Paper presented at the 3rd Conferences of the National Ereğli Vocational High School, University of Selcuk, Ereğli, 28-29 April, 2011 (In Turkısh)