## 25 Reputation

0 years, 101 days

## Define variable as the solution to a dif...

Maple 2019

Hey I’m trying to define a variable as the solution to a second order nonhomogeneous differential equation with an initial value problem.

I have tried the method below, but it doesn’t work.

N__1 := dsolve([diff(y(x), x, x) + 3*diff(y(x), x) + 2*y(x) = x^2 + 5, eval(y(x), x = 0) = 1, eval(diff(y(x), x), x = 0) = 1], y(x))

It kind of works it gives me the expression below

N__1 = y(x) = (3*exp(-2*x))/4 + 17/4 - (3*x)/2 + x^2/2 - 4*exp(-x)

But I need the expression for N__1 to define some initial values for N__2 and so on, what I have tried that doesn’t work is.

C := eval(N__1, x = 200)

N__2 := C   - Just because nothing much is happing on this interval

And it gives me the following expression for N2

N__2 := y(200) = (3*exp(-400))/4 + 78817/4 - 4*exp(-200)

I then make a piecewise function to make a function which I can plot, which use to work.

N := piecewise(0 <= x and x <= 200, N__1, 200 <= x and x <= 1000, eval(N__2, x = x - 200))

But when I’m trying to plot N maple gives me a warning message.

plot(N, x = 0 .. 1000)

Warning, expecting only range or variable x in expression piecewise ………………..  to be plotted but found name y.

If I define N__1 as the solution to the differential equation, then it works just fine.

N__1 := (3*exp(-2*x))/4 + 17/4 - (3*x)/2 + x^2/2 - 4*exp(-x)

But that I’m not interested in, because that will require a lot of copy paste all the time.

## Horizontally shifting...

Maple 2019

Hey I’m trying to shift a function horizontally to the right.

I have the following 3 functions:

V1 := -x

V2:= -2*x + 4.95

V3:= -x + 1.665

Function V2 I want to shift l_1 to the right, and V3 I want to shift l_1 + l_2 to the right.

I know I can do this manually by define the functions:

V2:= -2*(x-l_1) + 4.95

V3:= -(x-l_1-l_2) + 1.665

Where l_1:=1.665 and l_2:=4.95

Is there a way to do this without typing it manually?

By the way it’s only for plotting, so it’s not necessary for me to actually define them, if there is a way to do it within a plot some how.

## Define antiderivatives...

Maple 2019

Hey I’m trying to define the antiderivative for a function:

g(x) = 1

G(x) = int(g(x),x)

When I then type:

G(x) and press enter Maple gives me G(x) = x which of course is correct

But I can’t type:

G(5)

Then it gives me the error message:

Error, (in int) integration range or variable must be specified in the second argument, got 5

How to fix this?

I know I can type G(x) = x manually but I’m not interested in doing so, because in my document I’m going to have a lot of antiderivatives.