Skip to main content

Mathematical Function Solver from Dataset

Project description

# solverCan Mathematical Function Solver from Dataset by Emrecan Bayhan. Find equations from raw data using forward differences and derivative ratio analysis.

solverCan

Mathematical Function Solver from Dataset by Emrecan Bayhan

Find equations from raw data using forward differences, derivative ratio analysis, and piecewise polynomial approximation.

Installation

pip install solverCan

Quick Start

import solverCan

y = [14, 13, 14, 17, 22, 29, 38, 49, 62, 77]
result = solverCan.auto(y)
print(result['equation'])       # f(x) = x^2 - 4*x + 17
print(result['compute'](15))    # 182.0

Methods

1. Polynomial

r = solverCan.plynm(y)
print(r['equation'])        # f(x) = x^2 - 4*x + 17
print(r['degree'])          # 2
print(r['coefficients'])    # [17, -4, 1]

2. Exponential

y = [50000.0, 51522.73, 53091.83, 54708.71, 56374.84,
     58091.71, 59860.87, 61683.9, 63562.46, 65498.22]
r = solverCan.expo(y)
print(r['equation'])        # f(x) = 48512.25*exp(0.03*x) + 10.36

3. Trigonometric (Piecewise)

y = [200, 217.02, 232.95, 247.47, 260.31, 271.19, 279.9, 286.26,
     290.12, 291.42, 290.12, 286.26, 279.9, 271.19, 260.31, 247.47,
     232.95, 217.02, 200]
x = list(range(0, 95, 5))
r = solverCan.trig(y, x=x)
print(r['equation'])        # Two pieces

4. Trigonometric (Single Equation)

r = solverCan.trigOneEq(y, x=x)              # auto iterations
r = solverCan.trigOneEq(y, x=x, max_iter=2)  # fixed 2 iterations
print(r['equation'])
print(r['iterations'])

5. Irrational (Piecewise)

y = [24.0, 26.5858, 31.2679, 38.0, 46.7639,
     57.5505, 70.3542, 85.1716, 102.0, 120.8377]
r = solverCan.irrational(y)
print(r['equation'])

6. Irrational (Single Equation)

r = solverCan.irrationalOneEq(y)
r = solverCan.irrationalOneEq(y, max_iter=3)  # fixed iterations

7. Auto (Best Method)

r = solverCan.auto(y)
print(r['method'])          # Polynomial (degree 2)
print(r['equation'])
for name, info in r['all_results'].items():
    print(f"  {name}: {info['method']} (max dev: {info['max_deviation']:.4f}%)")

Visualization

Comparison Table

solverCan.table(y, r['compute'])

Comparison Graph

solverCan.compare_graph(y, r['compute'])
solverCan.compare_graph(y, r['compute'], title="My Analysis")
solverCan.compare_graph(y, r['compute'], save_as="output.png")

Custom X Values

x = [0, 5, 10, 15, 20]
y = [100, 250, 380, 470, 520]
r = solverCan.auto(y, x=x)

Prediction

r = solverCan.auto(y)
print(r['compute'](15))     # Predict at x=15
for x in range(11, 21):
    print(f"  x={x}: {r['compute'](x):.4f}")

Result Fields

All methods return a dict:

Field Description
r['equation'] Equation string
r['compute'](x) Predict value at x
r['method'] Method name
r['coefficients'] Polynomial coefficients (plynm, OneEq)
r['degree'] Polynomial degree (plynm)
r['parts'] Exponential parts (expo)
r['pieces'] Piecewise segments (trig, irrational)
r['iterations'] Iteration count (OneEq)
r['all_results'] All methods comparison (auto)

How It Works

  1. Forward Differences — Detects polynomial degree via CV analysis
  2. Gauss Elimination — Solves linear system for polynomial coefficients
  3. Derivative Ratios — Constant ratio = exponential function (e^ax)
  4. Iterative Correction — Find f1, compute residual, find f2, sum together
  5. Piecewise Splitting — Split at deviation breakpoints, fit each segment

Author

Emrecan Bayhan Email: bayhan.emrecan1@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solvercan-0.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solvercan-0.1.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file solvercan-0.1.1.tar.gz.

File metadata

  • Download URL: solvercan-0.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for solvercan-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f8863e26f5b79eb3f5dd28bd85391036e401f703e4d8f2a583345591b33962d7
MD5 d26ad6b2f1b1ede2572d720726d1b9ed
BLAKE2b-256 f9de80041800805f5c0a7a6653fe83ce8b02b0968cac6aab05db7b7b79d4559f

See more details on using hashes here.

File details

Details for the file solvercan-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: solvercan-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for solvercan-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7d355bc6c8e35870fdbbfddf87269ccfc47ffecdc86bd57c4a4cd0c87d4f648a
MD5 f031e6a6b7c75b2b57f40c2b7ef59936
BLAKE2b-256 9a96fe9a33c6076081e149aceb54ed75af75f16105ded9cf487008100647255a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page