# scicode / scicode-16

- taskset: [scicode](https://harnessreport.com/tasks/scicode.md)
- difficulty: hard
- category: scientific_computing
- language: 
- runnable from the site: no
- agent timeout: 1800s

## Results by harness

_none yet_

## Instruction

```
# SciCode Problem 16

Write a script to generate a symmetric matrix with increasing values (starting from 1 and increasing by 1) along its diagonal and then implement the Davidson's method for finding the first few lowest eigenvalues of this matrix. When generating the matrix, the user should be able to specify the dimension of the matrix. All elements in the matrix should be modified based on the product of a normally distributed random number generated by numpy and an input given by the user. When solving for the eigenvalues, the user should be able to specify the convergence threshold and the number of eigenvalues to be solved for.

'''
Inputs:
- matrixA: Symmetric matrix (2D array of float).
- num_eigenvalues: Number of lowest eigenvalues to compute (int).
- threshold: Convergence threshold for the algorithm (float).

Output:
- current_eigenvalues: computed eigenvalues (1D array of float).
'''

## Required Dependencies

```python
import math
import numpy as np
```

You must implement 2 functions sequentially. Each step builds on previous steps. Write ALL functions in a single file `/app/solution.py`.

## Step 1 (Step ID: 16.1)

Write a function to generate a symmetric matrix with increasing values along its diagonal.  All elements in the matrix should be modified based on the product of a normally distributed random number generated by numpy and an input given by the user. Symmetrize the matrix by taking the average of the sum of the matrix and its tranpose.

### Function to Implement

```python
def init_matrix(dim, noise):
    '''Generate a symmetric matrix with increasing values along its diagonal.
    Inputs:
    - dim: The dimension of the matrix (int).
    - noise: Noise level (float).
    Output:
    - A: a 2D array where each element is a float, representing the symmetric matrix.
    '''

return A
```

---

## Step 2 (Step ID: 16.2)

Write a function to implement the Davidson's method. The user should be able to set the convergence threshold and the number of eigenvalues to be solved.

### Function to Implement

```python
def davidson_solver(matrixA, num_eigenvalues, threshold):
    '''Implements the Davidson algorithm to compute the first few eigenvalues of a symmetric matrix.
    Inputs:
    - matrixA: Symmetric matrix (2D array of float).
    - num_eigenvalues: Number of lowest eigenvalues to compute (int).
    - threshold: Convergence threshold for the algorithm (float).
    Output:
    - current_eigenvalues: computed eigenvalues (1D array of float).
    '''

return current_eigenvalues
```

---

## Instructions

1. Create `/app/solution.py` containing ALL functions above.
2. Include the required dependencies at the top of your file.
3. Each function must match the provided header exactly (same name, same parameters).
4. Later steps may call functions from earlier steps — ensure they are all in the same file.
5. Do NOT include test code, example usage, or __main__ blocks.
```
---
Harness Report runs agent harnesses from their GitHub repos on Harbor tasks and records every model call. Every page is also `.md` and `.json`; index: https://harnessreport.com/llms.txt · MCP: https://harnessreport.com/mcp
