DDecayMarsh
Workflows

Coding workflows · Runge–Kutta decay steps

03
Built around your work

A concrete starting point

Integrate scalar exponential decay with up to 1000 classical Runge–Kutta steps using finite bounded inputs. Check zero steps and zero rate, reject negative values for rate or step size and reject their product above one.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Runge–Kutta decay steps

A concrete starting point
def decay_steps(initial, rate, dt, steps):
    if any(type(v) not in (int, float) for v in (initial, rate, dt)):
        raise ValueError("decay.numeric")
    if not -10**6 <= initial <= 10**6 or not 0 <= rate <= 1000 or not 0 <= dt <= 1 or rate * dt > 1:
        raise ValueError("decay.range")
    if type(steps) is not int or not 0 <= steps <= 1000:
        raise ValueError("decay.steps")
    y = float(initial)
    for _ in range(steps):
        k1 = -rate * y
        k2 = -rate * (y + dt*k1/2)
        k3 = -rate * (y + dt*k2/2)
        k4 = -rate * (y + dt*k3)
        y += dt*(k1 + 2*k2 + 2*k3 + k4)/6
    return y

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗