Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Solve functions in a system of equations

If I run the following code:

var('r')
f = function('f')(r)
g = function('g')(r)

eq1 = diff(f,r)+2*r
eq2 = diff(g,r) + diff(f,r) + 2*r

solve([eq1,eq2],diff(f,r),diff(g,r))

I get:

TypeError: diff(f(r), r) is not a valid variable.

However, solving eq1 or eq2 independently does provide a solution:

sage: solve(eq1, diff(f,r))
[diff(f(r), r) == -diff(g(r), r) + 6]

sage: solve(eq2, diff(g,r))
[diff(g(r), r) == diff(f(r), r) - 4]

What could be wrong here? In a system of equations 'Solve' only provides a solution if the unknowns are variables and not functions (or derivative of functions)?

Solve functions in a system of equations

If I run the following code:

var('r')
f = function('f')(r)
g = function('g')(r)

eq1 = diff(f,r)+2*r
eq2 = diff(g,r) + diff(f,r) + 2*r

solve([eq1,eq2],diff(f,r),diff(g,r))

I get:

TypeError: diff(f(r), r) is not a valid variable.

However, solving eq1 or eq2 independently does provide a solution:

sage: solve(eq1, diff(f,r))
[diff(f(r), r) == -diff(g(r), r) + 6]

sage: solve(eq2, diff(g,r))
[diff(g(r), r) == diff(f(r), r) - 4]

What could be wrong here? In Could it be that in a system of equations 'Solve' only provides a solution if the unknowns are variables and not functions (or derivative of functions)?

Solve functions in a system of equations

If I run the following code:

var('r')
f = function('f')(r)
g = function('g')(r)

eq1 = diff(f,r)+2*r
eq2 = diff(g,r) + diff(f,r) + 2*r

solve([eq1,eq2],diff(f,r),diff(g,r))

I get:

TypeError: diff(f(r), r) is not a valid variable.

However, solving eq1 or eq2 independently does provide a solution:

sage: solve(eq1, diff(f,r))
[diff(f(r), r) == -diff(g(r), r) + 6]

sage: solve(eq2, diff(g,r))
[diff(g(r), r) == diff(f(r), r) - 4]

What could be wrong here? Could it be that in a system of equations 'Solve' only provides a solution if the unknowns are variables and not functions (or derivative of functions)?

Solve functions in a system of equationsequations for functions

If I run the following code:

var('r')
f = function('f')(r)
g = function('g')(r)

eq1 = diff(f,r)+2*r
diff(f,r) + diff(g,r) == 6
eq2 = diff(f,r) - diff(g,r) + diff(f,r) + 2*r
== 4

solve([eq1,eq2],diff(f,r),diff(g,r))

I get:

TypeError: diff(f(r), r) is not a valid variable.

However, solving eq1 or eq2 independently does provide a solution:

sage: solve(eq1, diff(f,r))
[diff(f(r), r) == -diff(g(r), r) + 6]

sage: solve(eq2, diff(g,r))
[diff(g(r), r) == diff(f(r), r) - 4]

What could be wrong here? Could it be that in a system of equations 'Solve' only provides a solution if the unknowns are variables and not functions (or derivative of functions)?