dear community, I'm not a mathematician so please...
# mathematics
d
dear community, I'm not a mathematician so please forgive me if I can't express my concern correctly. In my scenario, I have X and Y values that represent a connection. I would now like to use any X value and calculate the Y for it. I've already done this in a spreadsheet using a 4th degree polynomial. Now my question, can I solve this question with kmath and if so, how? Thank you for your time and effort. Daniel
i
Do you mean you need to approximate a function?
d
So far i know is that is also being called "Curve Fitting".
i
That's what I was able to craft using Chat GPT and notebooks. However, @altavir maybe can suggest a solution with using commons math https://gist.github.com/ileasile/56d34ad232ef16dba578141f02fabc24
d
Thank you for your efforts. I know about commons.math3 but i need kotlin for my kotlin-js thing. I forgot to mention that i got this info too.
a
Yes, @Daniel Rindt it is possible to add first-class support for polynomial fitting into KMath. I've put it into TODO list, but it won't be fast. If you need JS version, it is possible to replace CM fitter with QOW fitter. I will modify it later.
And it will work on JS
i
I've also updated a gist and added a pure Kotlin solution - in case it's the only problem you need math for
a
@Daniel Rindt I've updated the report: https://datalore.jetbrains.com/view/notebook/DDsWb8KgH71TgC7qsKDGs1. It is now even more simple. And it uses Quasi-optimal weights fittet, which is multiplatform. It should work on JS.
d
Thank you so much guys for your kind help and specially to @altavir. I will try now the example. Thank you a lot!
a
Feel free to write here if you have any problems.
d
Guys, i am not able to manage it to get compiling. What i can not find is the imports for DoubleVector and bindSymbolOrNull. Also generating the Range doesn't work. I tried this in the kotlin-js (multiplatform) module. Thank you for any further input to solve the issues.
a
I will try to run the example on JS. But in principle it should work.
d
I have played hours now with the imports and packages. No luck so far.
a
I will create a stand-alone application for demonstration then.
d
That would be somewhat great! I have actually everything in a Test.kt file. Just to see if it worked with my values. Thank you for your efforts! I highly appreciate it.
a
@Daniel Rindt Here is a working project on JS: https://github.com/SPC-code/kmath-js-demo. It requires some additional imports compared to notebook.