This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts

problemAIAlgebra 2

Solve the quadratic

A ball is thrown straight up at 4 m/s from 1 m above the ground. When does it land? Write roots(a, b, c), the two solutions of , smaller first.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

A ball is thrown straight up at 4 m/s from 1 m above the ground. With rounded to 10 m/s², its height after seconds is

It lands when , that is, when .

Write roots(a, b, c), the two solutions of , smaller first. You may assume . The tests use the ball and a rectangle with a perimeter of 10 and an area of 6, whose sides and satisfy .

Your task

Write this function:

roots(a, b, c)
The two roots of the quadratic with coefficients a, b and c, smaller first.

Make these tests pass 2 of 2 fail

  • $x^2 - 5x + 6 = 0$ gives 2 and 3 assert_near: |0 - 2| = 2 > 1e-12 (and 1 more) (fails)
  • $-5t^2 + 4t + 1 = 0$ gives -0.2 and 1, smaller first assert_near: |0 - -0.2| = 0.2 > 1e-12 (and 1 more) (fails)

Printed

t1: 0 t2: 0

Solutions 1

1 solution is posted. It is hidden until you have solved it yourself.

Read it anyway

Checked when the site was built: 0 of 2 tests passed (2 left to solve), in under 0.1 s. Download 2026-09-22-solve-the-quadratic.viv