I make a math library for my own programming language. I want know what functions there should be, but I don't know math.
The library contain sin, asin, sinh, asinh and other trigonometic functions, log/ln/lg/lb, sigmoid, transpose. Also I going to add interpolation and other functions to image/tensor processing. Also I would like to know, if is there application to integration and differentiation of functions. In my language is callable objects, so I can easly replace sin() function to same object, that calls as sin(), and has deriviative and antiderivative functions. I also want know functions to process tensors, such as transpose and interpolation of images, Ghaus what.
Also I want to know about optimizations. At some day I got knowledge how to compute Fibonachi by matrixes, but I didn't understand yet. Also I think about memoization, caching of results.
What do you think?
How can you be a programmer yet have such weak math skills?
>interpolation
There are several methods for doing interpolation and different methods have different parameters and different minimum amount of points.
>derivative and antiderivative functions
How do you plan to implement these? Are you always going to be using dual numbers for everything all the time so that you can take the derivative at any time? Or are you planning it to be done symbolically?
>>3710 I was thinking about writing a math lib where every function was defined as it's taylor series. You could easily take derivative, definite integral, any composition of functions, and notably any inverse of a function. Taylor series are accurate over way to small a domain for this to be practical for very much though, so it would end up only a toy.
>>3710 I was thinking about table data where a function has deriviative and antideriviative, and according to the rules deriviate and antideriviate, if there will be sin function, then sin object has deriviative and antideriviative. Something like this.
Main question is how much useful this would be?
>>3719 Suppose your table said that the antiderivative for e^x is e^x, and the antiderivative for x^2 is x^3/3. What does your program say the antiderivative of e^(x^2) is?
it doesn't, because such a function has no analytic solution
>>3720 Nothing, maybe.
I meant rules such as + and - if I properly remember, there is splitiing. I don't remember. Integral.
Sorry I can't think because of voices. Now is Easter. Many voices, hate loud voices.
I meant rules such as + and - and in my language classes (No, there is structs and unions. But there is generic. Load voices, load voices. Generc, generic. Yes, thith can't. I don't remember. I hate Easter. Why people do holydays? Holydays isn't important). Okay, walk away and remember.
I remembered. generic have struct or union elements, but the same classes can have same elements, but overloaded operators.
It's not important now. I hate Easter and holydays because of loud voices.
I meant rules such as + and - if I properly remember, there is splitting. And classes for formulas, that can have deriviative and antideriviative.
But I yet not know, is there a profit?
>>3723 Consider 3 cases:
0. A programmer discovered my programming language.
"Hey, why there isn't a math library? Ho to sine and cosine???"
"Is there some input-output library?"
"I wnat to make socket data flow, how???"
1. I make wrapper for C math library. A programmer discovered the programming language.
"Hff, sine, cosine, like at my c plus plus. Language intredasting... I don't want learn this."
2. A programmer-entusiast discovered my programming language, makes a supermath library.
>sine, cosine etc have hardcoded accuracy.
>Using f32e8 (C float, IEEE 754 single) instead of rational float "for speed" because of "calculating speed"
(Compiler must optimizate. If function that takes 2 floats, called with f32e8 in cycle or each constuction (in my PL for parallel programming), there should be compiled fast f32e8 function)
>Not using polymorphism where should, because of "C compatibaltit"
(there is my PL func and C c.func types, in further, cpp.func, python.func etc, so he can make multilangauge support)
Even if I'd make compiler or interpreter for my programming language, it need some libraries. I don't want include .h headers and parse it to my PL parsed datatree.
So, I need firstly make some libraries.
Reserved library names:
audio. Collection of audio formats.
avs. Audio-video-subtitle, collection of videocontainter formats.
c. C types.
dapa. Data parsing, byte strings, text string, numbers.
fs. File System. Directories, files, modes, tags, links, file devices, etc.
io. Input-output to files. Extendable to sockets, representation, maybe something else.
math. Math library.
module. Dynamic module loading. Binary libraries, executable files, scripts.
opengl. OpenGL.
os. OS interaction, malloc, realloc, free, exit.
raising. Python-like exception handling, throwing errors to users.
repr. Representation computer data to human-readable data.
sdl2. SDL2 binding.
socket. Sockets.
stdio. Small file for POSIX (?) stdin, stdout, stderr.
subprocess. Processes like in Python subprocess.
thread. OS threads.
video. Collection of video-formats, including images (PNG,JPG,TIFF), old animations (GIF) and modern video-formats such as H264 (? patenting?), VP8, VP9.
I'm writing compiler with python. pyparsing and llvmlite.
If I make dapa and LLVM library binding, then I would rewrite compiler to my PL.
>>3724 >0. A programmer discovered my programming language. "Hey, why there isn't a math library? Ho to sine and cosine???" "Is there some input-output library?" "I wnat to make socket data flow, how???"
and another shit PL with all thought going into how to make libs and copy C was born
>>3701 >Also I going to add interpolation
I'm implementing this right now and you need to write it in assembly for it to be fast enough. All video and image processing right now is either done in hardware or optimized SIMD assembly. Optimizing PLs are dead.
>>3727 Yes, In my language you can choose uN, sN, rNeM, fNeM with any bits. It's unsigned int, signed int, unsigned float-point, signed float point. First integer is bits, second is mantissa. Also there is int — integer, float — rational and string — bytes, that isn't static sized.
fNeM, I haven't figured it out yet. Bit fields corresponds to same as IEEE 754. I know about representation, where NaN/-NaN, infinity/-infinity. About single (f32e8) and double (f64e11) people in wikipedia writed. I don't know, is it architecture-dependent, operations.
I can write in documentation of my language, that behavior of operators to fNeM and rNeM is undefined, but same as on target architecture if such type supported (frequently half and single on GPU, single on ARM, single and double on AArch64, single, double, maybe 40-bit and 80-bit on x86-64).
>>3728 >you
No, you! I would take you contibuting, when my compiler-interpreter prepared.
Libraries of my language can have source code, manifest and compiler-module. Source code is source code of the library. My language normally is interpreted, but can be compiled. Manifest keeps data about binary library static and dynamic linking. And compiler-module is loaded module that can manipulate code and compilation as it wants. It's profitful in language-supporing module, such as C c library, imported with @import c!;. Yes, It's unsafe. I'm going to make my site about language and there will be library of libraries from me and other authors if they want when write. I wouldn't add binary compiler-module that not from me, but source-code-module such as pythonic or my PL if it can be loaded by compiler.
Okay, I just wrote some draft functions:
linErp — linear interpolation. If I remember propely, formula is y = y0 + (y1 - y0)*x, where y1 > y0 and x is [0,1].
biLinErp — bilinear interpolation. If I understood well, N-dimensional linear interpolation is linear interpolation of prev products, so I wrote
nLinErp — linear interpolation for n-dimension. My PL has T[] type, dynamic array, where T — base type, T[][] — 2-dimensional, T[][][] — 3-dimensional, T[[]] — n-dimensional. Dynamic arrays is for memory allocation and garbage collection, though it's just freeing of dynamic sized local variables on function return.
My language has `each` construction for parallel programming, so same code can be executed on either CPU or GPU or other computational units. I'm going to add OpenCL to compiler when it will be prepared and rewrited to my PL.
resize2 — pixel 2-dimensional resizing function, no interpolation. There is `each` construction that defines instructions for each x in range(0,width) if pythonic or 0:width if my PL, and y in 0:height.
I see multiCPU and, maybe GPU paralleling, but SIMD and it's a problem.
Your programming language is retarded. Ask yourself :
- How is my language different?
- What use case does it fit?
- Is it worth the time investment?
- Would anybody be interested?
- Is another language not already close enough? Can't I contribute to or fork that one?
My programming language is beautiful.
My language is very different to other PLs.
General-purpose programmings, MCU programming, parallel and claster computation, neural networks.
YES.
Maybe.
No, I can't.
Problem:
float have infinity accuracy and it's rational number. In my PL is power operator . Okay if power is integer, but fractional number.
If it's 250.5, it's also okay, but 2**0.5, which irrational number. int, uN, sN, f/rNeM has finite accuracy, so for this it's okay and power can be any rational number.
I can raise exception for float when power is fractional, but I want throw exception only if shall be irrational number. Maybe it's bad idea.
How to detect if power makes irrational number?
I make a math library for my own programming language. I want know what functions there should be, but I don't know math.
The library contain sin, asin, sinh, asinh and other trigonometic functions, log/ln/lg/lb, sigmoid, transpose. Also I going to add interpolation and other functions to image/tensor processing. Also I would like to know, if is there application to integration and differentiation of functions. In my language is callable objects, so I can easly replace sin() function to same object, that calls as sin(), and has deriviative and antiderivative functions. I also want know functions to process tensors, such as transpose and interpolation of images, Ghaus what.
Also I want to know about optimizations. At some day I got knowledge how to compute Fibonachi by matrixes, but I didn't understand yet. Also I think about memoization, caching of results.
What do you think?