Solve the piecewise linear ODE, y' - y = f(x), y(0) = 1, where f(x) = 1 when 0 \le x \le 1 and f(x) = -1 when x > 1. What is y(2)? Round to the nearest tenth.

I stated and got

y'-y= ce^x , but wasn't really sure if that was right so I didn't know where to go from there.

y'-y = 1: y = ce^x - 1 for 0<=x<=1

y'-y = -1: y = ce^x + 1 for x>1

y(0) = 1 means c=2, so
y = 2e^x - 1 for 0<=x<=1

If we want y to be continuous, then since y(1) = 2e-1,
y = (2 - 2/e)e^x + 1 for x>1
Thus,
y(2) = (2 - 2/e)e^2 + 1 = 2e^2-2e+1

To solve the given piecewise linear ordinary differential equation (ODE), let's break it down into two cases.

Case 1: 0 ≤ x ≤ 1
In this case, the ODE becomes:
y' - y = 1

This is a first-order linear ODE, and we can solve it by using an integrating factor. The integrating factor is given by e^(-x), so we multiply the entire equation by e^(-x) to obtain:
e^(-x)y' - e^(-x)y = e^(-x)

Now, we can recognize the left-hand side as the derivative of (e^(-x)y), applying the product rule. Thus, we have:
d/dx (e^(-x)y) = e^(-x)

Integrating both sides of the equation with respect to x gives:
e^(-x)y = -e^(-x) + C1

To solve for y, divide both sides by e^(-x):
y = -1 + Ce^x ... (1)

Case 2: x > 1
In this case, the ODE becomes:
y' - y = -1

Again, this is a first-order linear ODE and we follow the same steps as in the previous case. Multiply the entire equation by e^(-x), and we get:
e^(-x)y' - e^(-x)y = -e^(-x)

Using the same integrating factor, we have:
d/dx (e^(-x)y) = -e^(-x)

Integrating both sides with respect to x and applying the chain rule, we have:
e^(-x)y = e^(-x) + C2

Divide both sides by e^(-x) to solve for y:
y = 1 + Ce^x ... (2)

Now, we need to find the values for C1 and C2.

Given that y(0) = 1, we can substitute this initial condition into equations (1) and (2).

For Case 1 when 0 ≤ x ≤ 1:
1 = -1 + Ce^0
1 = -1 + C
C = 2

For Case 2 when x > 1:
1 = 1 + Ce^0
1 = 1 + C
C = 0

Now, using the appropriate equation for the given value of x, we can find y(2).

For 1 ≤ x ≤ 2 (belongs to Case 2):
y = 1 + 0e^x
y = 1

Therefore, y(2) = 1, rounded to the nearest tenth.

To solve the given piecewise linear ordinary differential equation (ODE) y' - y = f(x), we first need to find the solution to the homogeneous ODE, which is the ODE y' - y = 0.

The characteristic equation for this homogeneous ODE is obtained by assuming y = e^(rx), where r is a constant:

r e^(rx) - e^(rx) = 0

Factoring out e^(rx), we get:

e^(rx) (r - 1) = 0

The exponential term e^(rx) does not equal zero for any value of r, so the other factor must be zero:

r - 1 = 0

This gives us r = 1 as the only solution.

Therefore, the general solution to the homogeneous ODE is y_h(x) = c e^(1x), where c is a constant.

Now, we need to find the particular solution for the non-homogeneous part of the ODE, which is f(x).

When 0 ≤ x ≤ 1, f(x) = 1. To find the particular solution for this interval, we can assume y_p(x) = A for some constant A.

Plugging this assumption into the ODE, we get:

0 - A = 1

A = -1

So, for 0 ≤ x ≤ 1, the particular solution is y_p(x) = -1.

When x > 1, f(x) = -1. To find the particular solution for this interval, we can assume y_p(x) = B for some constant B.

Plugging this assumption into the ODE, we get:

0 - B = -1

B = 1

So, for x > 1, the particular solution is y_p(x) = 1.

The general solution to the non-homogeneous ODE is the sum of the homogeneous and particular solutions:

y(x) = y_h(x) + y_p(x)

For 0 ≤ x ≤ 1, the complete solution is y(x) = c e^x - 1, where c is a constant.

For x > 1, the complete solution is y(x) = c e^x + 1, where c is a constant.

Now, we can apply the initial condition y(0) = 1 to find the value of the constant c.

For x = 0, the solution is y(0) = c e^0 - 1 = c - 1.

Setting y(0) = 1, we have:

c - 1 = 1

c = 2

Therefore, the complete solution to the ODE is:

For 0 ≤ x ≤ 1: y(x) = 2e^x - 1
For x > 1: y(x) = 2e^x + 1

We are now asked to find y(2). Plugging x = 2 into the solution, we get:

y(2) = 2e^2 + 1

Evaluating this expression to the nearest tenth, we find:

y(2) ≈ 15.4