import
java.util.*;
class
Node {
public
int
data;
public
int
pow1;
public
int
pow2;
public
Node link1;
public
Node link2;
public
Node(
int
d,
int
p1,
int
p2)
{
data = d;
pow1 = p1;
pow2 = p2;
link1 =
null
;
link2 =
null
;
}
}
class
GFG {
public
static
Node input_equation(Node head,
int
d,
int
p1,
int
p2)
{
Node temp = head;
if
(head ==
null
) {
Node ptr =
new
Node(d, p1, p2);
head = ptr;
}
else
{
temp = head;
while
(temp.link2 !=
null
) {
temp = temp.link2;
}
Node ptr =
new
Node(d, p1, p2);
ptr.link1 = temp;
temp.link2 = ptr;
}
return
head;
}
public
static
void
derivation_with_x(Node head)
{
String tem =
"Partial derivatives w.r.t. x: "
;
Node temp = head;
while
(temp !=
null
) {
if
(temp.pow1 !=
0
) {
temp.data = (temp.data) * (temp.pow1);
temp.pow1 = temp.pow1 -
1
;
}
else
{
temp.data =
0
;
temp.pow1 =
0
;
temp.pow2 =
0
;
}
temp = temp.link2;
}
temp = head;
if
(temp.data !=
0
) {
tem = tem +
" "
+ temp.data +
"(x^"
+ temp.pow1
+
" y^"
+ temp.pow2 +
")"
;
}
temp = temp.link2;
while
(temp !=
null
) {
if
(temp.data !=
0
) {
tem = tem +
" + "
+ temp.data +
"(x^"
+ temp.pow1 +
" y^"
+ temp.pow2 +
")"
;
}
temp = temp.link2;
}
System.out.println(tem);
}
public
static
void
derivation_with_y(Node head)
{
String tem =
"Partial derivatives w.r.t. y: "
;
Node temp = head;
while
(temp !=
null
) {
if
(temp.pow2 !=
0
) {
temp.data = (temp.data) * (temp.pow2);
temp.pow2 = temp.pow2 -
1
;
}
else
{
temp.data =
0
;
temp.pow1 =
0
;
temp.pow2 =
0
;
}
temp = temp.link2;
}
temp = head;
if
(temp.data !=
0
) {
tem = tem +
" "
+ temp.data +
"(x^"
+ temp.pow1
+
" y^"
+ temp.pow2 +
")"
;
}
temp = temp.link2;
while
(temp !=
null
) {
if
(temp.data !=
0
) {
tem = tem +
" + "
+ temp.data +
"(x^"
+ temp.pow1 +
" y^"
+ temp.pow2 +
")"
;
}
temp = temp.link2;
}
System.out.println(tem);
}
public
static
void
derivation_with_x_y(Node head)
{
String tem =
"Partial derivatives w.r.t. xy: "
;
Node temp = head;
while
(temp !=
null
) {
if
(temp.pow1 !=
0
&& temp.pow2 !=
0
) {
temp.data = (temp.data) * (temp.pow1)
* (temp.pow2);
temp.pow1 = temp.pow1 -
1
;
temp.pow2 = temp.pow2 -
1
;
}
else
{
temp.data =
0
;
temp.pow1 =
0
;
temp.pow2 =
0
;
}
temp = temp.link2;
}
temp = head;
if
(temp.data !=
0
) {
tem = tem +
" "
+ temp.data +
"(x^"
+ temp.pow1
+
" y^"
+ temp.pow2 +
")"
;
}
temp = temp.link2;
while
(temp !=
null
) {
if
(temp.data !=
0
) {
tem = tem +
" + "
+ temp.data +
"(x^"
+ temp.pow1 +
" y^"
+ temp.pow2 +
")"
;
}
temp = temp.link2;
}
System.out.println(tem);
}
public
static
void
main(String[] args)
{
Node head =
null
;
head = input_equation(head,
2
,
3
,
4
);
head = input_equation(head,
3
,
5
,
7
);
head = input_equation(head,
1
,
2
,
6
);
derivation_with_x(head);
derivation_with_y(head);
derivation_with_x_y(head);
}
}