Opened 12 years ago

Closed 8 years ago

# desolve mixes user parameters and integration constants

Reported by: Owned by: Paul Zimmermann Burcin Erocal major sage-6.2 calculus Robert Marik, Karl-Dieter Crisman Paul Zimmermann Ralf Stephan N/A

### Description

Consider

```sage: var('t')
sage: x=function('x',t)
sage: var('c')
sage: desolve(diff(x,t)+2*x==t^2-2*t+c,x,ivar=t).expand()
c*e^(-2*t) + 1/2*t^2 + 1/2*c - 3/2*t + 3/4
```

Here the first occurrence of `c` is an integration constant, whereas the second one is the parameter in the ODE:

```sage: var('d')
sage: desolve(diff(x,t)+2*x==t^2-2*t+d,x,ivar=t).expand()
c*e^(-2*t) + 1/2*t^2 + 1/2*d - 3/2*t + 3/4
```

In case the ODE contains `c`, desolve should choose another name for the integration constant.

### comment:1 Changed 12 years ago by Robert Marik

Cc: Robert Marik added

This is a part of more general problem which has been reported in #6882.

### comment:2 Changed 12 years ago by Karl-Dieter Crisman

Cc: Karl-Dieter Crisman added

### comment:3 Changed 9 years ago by Jeroen Demeyer

Milestone: sage-5.11 → sage-5.12

### comment:4 Changed 9 years ago by Paul Zimmermann

Authors: → Paul Zimmermann new → needs_review

waiting for the general problem to be solved, the attached patch prints a warning if the given equation contains the variable `c`.

Paul

### comment:5 Changed 9 years ago by For batch modifications

Milestone: sage-6.1 → sage-6.2

### comment:6 Changed 9 years ago by Ralf Stephan

Reviewers: → Ralf Stephan needs_review → positive_review

I will OK this if you have a look at #8734 in turn, please 8)

Version 0, edited 9 years ago by Ralf Stephan (next)

### comment:7 follow-up:  8 Changed 9 years ago by Paul Zimmermann

thus should we have a dependency on #8734?

Paul

### comment:8 in reply to:  7 Changed 9 years ago by Ralf Stephan

thus should we have a dependency on #8734?

Then everything waits for that review, which could take forever. But I want the warning now.

### comment:9 Changed 9 years ago by Nils Bruin

You might want to consider this one too:

```sage: desolve(diff(f(x),x,x)-f(x),f(x))
k2*e^(-x) + k1*e^x
```

We can recognize the variables as distinct before they are converted from maxima:

```sage: function('f',x)
f(x)
sage: var('c')
c
sage: V=diff(f(x),x)-f(x)+c
sage: v=maxima_calculus(V)
sage: v.ode2(f(x),x)
'f(x)=(c*%e^-x+%c)*%e^x
sage: v.ode2(f(x),x).ecl()
<ECL: ((MEQUAL SIMP) ((%F SIMP) \$X)
((MTIMES SIMP)
((MPLUS SIMP) \$%C
((MTIMES SIMP) \$C ((MEXPT SIMP) \$%E ((MTIMES SIMP) -1 \$X))))
((MEXPT SIMP) \$%E \$X)))>
```

so perhaps the right solution is to warn when sage's "forget the %" causes a name collision (with the righter solution being: making sage's "forget the %" more intelligent, so that collisions can be avoided)

### comment:10 Changed 9 years ago by Ralf Stephan

With #16007 the output is now

```sage: sage: x=function('x',t)
sage: sage: var('c')
c
sage: sage: desolve(diff(x,t)+2*x==t^2-2*t+c,x,ivar=t).expand()
1/2*t^2 + _C*e^(-2*t) + 1/2*c - 3/2*t + 3/4

sage: desolve(diff(f(x),x,x)-f(x),f(x))
_K2*e^(-x) + _K1*e^x
```

As that's a simple and fine solution instead of a warning or an extended patch I would be glad if someone could review that one-liner.

### comment:11 Changed 8 years ago by Volker Braun

Resolution: → duplicate positive_review → closed
Note: See TracTickets for help on using tickets.