Ask Your Question

# Substitute formal function by an expression in a differential equation

This is a follow up to substitute expression instead of formal function symbol. I tried to no avail to apply the workaround proposed there for the following application where I build a differential equation involving a formal function P:

  sage: x,y = var('x,y')
sage: P = function('P',x,y)
sage: z = var('z')
sage: C = function('C',z)
sage: equation = P(x=z,y=C) == 0
sage: dequation = diff(equation, z)


and then I would want to substitute P by a specific expression:

  sage: Q(x,y) = y^2 - y + x
sage: dequation.substitute_function(P,Q)


But whatever I tried, I got:

   D(C)(z)*D(P)(z, C(z)) + D(P)(z, C(z)) == 0


Is there a natural syntax to achieve this? If not, should this be a ticket?

Thanks!

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

This is a bug and it's already on trac: 6480

Unfortunately GiNaC doesn't support pattern matching with functions, or substituting functions (like substitute_function()). This is partly due to the fact that defining symbolic functions at runtime is a Python luxury, which you don't get in a convenient form using C++.

Asking on the GiNaC lists about how to do this would be a good start. At the moment I don't have too much time to start looking at this myself.

more

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2011-08-25 10:24:25 +0200

Seen: 1,476 times

Last updated: Sep 01 '11