Ask Your Question

Substitute formal function by an expression in a differential equation

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

Nicolas M Thiéry gravatar image

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[0](C)(z)*D[1](P)(z, C(z)) + D[0](P)(z, C(z)) == 0

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


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2011-09-01 07:23:32 +0200

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.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


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

Seen: 1,660 times

Last updated: Sep 01 '11