Coder Social home page Coder Social logo

eo-math's Introduction

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

mvn PDD status codecov Maven Central Hits-of-Code Lines of code License

EOLANG objects for trigonometry and floating point opeartions.

This is how you can manipulate with sin, cos, tan and ctan via angle:

+alias org.eolang.math.pi
+alias org.eolang.math.angle

(angle pi).cos > cos-pi
(angle (angle 30).as-radians).sin > thirty-degrees-sin
(angle (pi.div 3.0)).tan > pi-div-three-tan

You are welcome to add more primitives to this lib. You can see what we need in the lib in the paper.

How to Contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install -Pqulice

You will need Maven 3.3+ and Java 8+.

eo-math's People

Contributors

c71n93 avatar graur avatar includealex avatar kerelape avatar levbagryansky avatar masynchin avatar maxonfjvipon avatar mximp avatar renovate[bot] avatar rultor avatar yegor256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eo-math's Issues

number.eo:355-356: Natural logarithm should be...

The puzzle 53-f25515fd from #53 has to be resolved:

# @todo #53:30min. Natural logarithm should be implemented in EO when there
# is an object or an atorm that can calculate a series.

The puzzle was created by @rultor on 07-Nov-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

int8 , int16 , int32 and int128 objects

According to this paper (p. 7 Digits) we need to add int8 , int16 , int32 and int128 objects, which are decorators of bytes with a predefined size. They implement the same numeric operations as int.

to move objects from `eo-runtime` of EO

It would be great if we could move objects from org.eolang.math package of eo-runtime (in EO) to this eo-math project.
Since we get rid of them from float.eo and int.eo according to this. Here they are:

  • angle.eo
  • number.eo
  • random.eo
    and some tests for them

@maxonfjvipon You can leave them as is or redo them. It's up to you. But keep the tests untouched please.
I can provide some help with this issue, if you want.

Every operations with NaN should return NaN

Accordingly to IEEE 754 NaN should be a result of next operations:

  1. Every math operations with NaN as argument
  2. 0 / 0
  3. ∞ / ∞
  4. 0 * ∞
  5. ∞ + (-∞) = ∞ - ∞ = -∞ + ∞
  6. sqrt(x) if x < 0 (if EO will not support complex arithmetics)
  7. log(x) and ln(x) if x < 0 (if EO will not support complex arithmetics)
  8. powr(+-0, +-0) (powr(x, y) is pow(x, y), but x ∈ [0,+∞] when in pow(x, y) x ∈ [-∞, +∞])

number.sqrt object

There is a separate function of sqrt in defferent languages. For instance Math.sqrt in java. I think it would be useful to have this object too. We can use Heron's iterative formula instead of calculating method in number.power because the formula has a good convergence rate:
$$\sqrt{S} = \lim\limits_{k \to \infty} x_{k}$$
$$x_{k+1} = \frac{1}{2} * (x_{k} + \frac{S}{x_{k}}) $$
@Graur @EugeneDar WDYT?

number.is-close

@Graur @maxonfjvipon
I think it would be convenient to use number.is-close in order to comparison floats. I would simplify coding tests
WDYT about introducing this object?
[accuracy other] > close

number.eo:295-297: min. Implement cos using this taylor...

The puzzle 56-447424ab from #56 has to be resolved:

# @todo #56:90 min. Implement cos using this taylor object.
# You need to code function for coefficient of nth term.
# Accuracy can be decreased because of stack limitation.

The puzzle was created by @levBagryansky on 10-Nov-22.

Estimate: 90 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

number.eo:338-341: min. Implement sqrt without using...

The puzzle 89-b869de10 from #89 has to be resolved:

# @todo #89:90 min. Implement sqrt without using number.pow.
# We need it because pow is atom and supposed to be removed.
# You can use Heron's iterative formula with a quite good
# convergence rate.

The puzzle was created by @levBagryansky on 24-Nov-22.

Estimate: 90 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

`eo-math` release

We need to:

  • create corresponding release of eo-math
  • add all .eo files from eo-math to objectionary/home project (by .sh script)

after #25

number.eo:291-293: min. Implement sin using this taylor...

The puzzle 56-3e56337e from #56 has to be resolved:

# @todo #56:90 min. Implement sin using this taylor object.
# You need to code function for coefficient of nth term.
# Accuracy can be decreased because of stack limitation.

The puzzle was created by @levBagryansky on 10-Nov-22.

Estimate: 90 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

random.eo:67-69: Add a case if there is windows. Improve...

The puzzle 35-8e3580f7 from #35 has to be resolved:

# @todo #35:30min. Add a case if there is windows. Improve
# imlementation for windows if there is ability to get
# time for windows and enable tests for these cases.

The puzzle was created by @levBagryansky on 01-Dec-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Problem with meta

I want to use mod object in my program:

+alias org.eolang.txt.sprintf
+alias org.eolang.io.stdout
+alias org.eolang.txt.text
+alias org.eolang.math.number

[args...] > main
  [y] > leap
    or. > @
      and.
        eq. (mod. y 4) 0
        not. (eq. (mod. y 100) 0)
      eq. (mod. y 400) 0
  stdout > @
    sprintf
      "%d is %sa leap year!"
      (text (args.at 0)).as-int > year!
      if. (leap year:y) "" "not "

but I get this error. What could be wrong?

[ERROR] [main:4] The alias "org.eolang.math.number" is not used (unused-aliases:27)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codecov.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/cache v3
  • codecov/codecov-action v4.0.0-beta.3
  • ubuntu 22.04
.github/workflows/mvn.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/cache v3
.github/workflows/pdd.yml
  • actions/checkout v4
  • ubuntu 22.04
.github/workflows/xcop.yml
  • actions/checkout v4
  • ubuntu 22.04
maven
pom.xml
  • com.jcabi:parent 0.66.0
  • org.eolang:eo-runtime 0.32.0
  • org.junit.jupiter:junit-jupiter-api 5.9.1
  • org.junit.jupiter:junit-jupiter-params 5.9.1
  • org.apache.maven.plugins:maven-compiler-plugin 3.8.1
  • org.eolang:eo-maven-plugin 0.32.0
  • com.qulice:qulice-maven-plugin 0.22.0

  • Check this box to trigger a request for Renovate to run again on this repository

`ceil` object

We need to add number.ceil object according to this:
• ceil : round itself up

max and min in a "series"

Would be nice to introduce a new object series, which would decorate an array. Then, we can have max and min:

max.
  QQ.math.series
    *
      5
      13
      -9

Later, we can implement series.sum, series.average, series.expectancy, etc.

Release

I needed sqrt attribute of number, but it wasn't in release. There were implemented list of things, maybe we can make a release?

series.eo:34-35: The array may consist of objects of any...

The puzzle 36-165baf3b from #36 has to be resolved:

# @todo #36:30min. The array may consist of objects of any type. `max`
# and `min` objects should work only with an array of numbers.

The puzzle was created by @yegor256 on 24-Sep-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

number.eo:299-301: min. Implement tg using this taylor...

The puzzle 56-d42fb220 from #56 has to be resolved:

# @todo #56:90 min. Implement tg using this taylor object.
# You need to code function for coefficient of nth term.
# Accuracy can be decreased because of stack limitation.

The puzzle was created by levBagryansky on 10-Nov-22.

Estimate: 90 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Read.me

It seems we need more attractive readme

Can't build `eo-math` in the master branch

I've run the next command:

 mvn clean package 

Expected behaviour: eo-math compiles successfully and all compiled files and classes are placed in target folder.
Actual: I get the next exception during the build:

[ERROR] Failed to execute goal org.eolang:eo-maven-plugin:0.28.10:transpile (compile) on project eo-math: Execution compile of goal org.eolang:eo-maven-plugin:0.28.10:transpile failed: XPath '@check' not found in '<error line="32" severity="warning" sheet="not-emp..16..)' contains redundant parentheses</error>\uA': Index (0) is out of bounds (size=0) -> [Help 1]

pom.xml

pom.xml isn't completed, need to add more info to it.

upgrade to EO 0.28.0

After the changes introduced in EO 0.28.0, one of the tests fail here:

EOorg.EOeolang.EOmath.EOmod_into_while_and_seq_objectsTest.testWorks()  Time elapsed: 0.024 sec  <<< FAILURE!
org.opentest4j.AssertionFailedError:
Expected: <5> equal to value
     but: was <false>
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:39)
	at org.junit.jupiter.api.Assertions.fail(Assertions.java:117)
	at EOorg.EOeolang.EOmath.EOmod_into_while_and_seq_objectsTest.testWorks(EOmod_into_while_and_seq_objectsTest.java:170)

Please, upgrade and release new version of eo-math.

Unsorted metas in `number.eo`

Compiling eo-runtime the following error occurs:

[WARNING] [org.eolang.math.number:24] Meta is out of order: "alias org.eolang.math.negative-infinity" (unsorted-metas:13)

Build fails due to failOnWarning enabled in eo-runtime.
The warning needs to be fixed in number.eo.
Also the same flag needs to be enabled in eo-math

number.eo:186-188: min. Improve performance to be able to...

The puzzle 21-9a1034f5 from #21 has to be resolved:

# @todo #21:30 min. Improve performance to be able to work with big numbers.
# Should use binary exponentiation. It allows to raise any number to the n'th
# power in O(log n) multiplications

The puzzle was created by maximtrunnikov on 19-Sep-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

integral-tests.eo:71-75: This test fails due to incorrect...

The puzzle 93-b28a2be4 from #93 has to be resolved:

# @todo #93:30min This test fails due to
# incorrect choose of steps in the
# integral implementation. For excluding
# this error, Simpson's rule for
# determing n should be written.

The puzzle was created by @rultor on 29-Nov-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

number-tests.eo:317-320: We need to remove this nop...

The puzzle 42-658d578c from #42 has to be resolved:

# @todo #42:30min We need to remove this
# nop object after objectionary/home
# was released and after EO version will
# be up to 0.28.0

The puzzle was created by @Graur on 01-Sep-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

infinity objects needed

We need a positive-infinity (1.0 / 0.0) and negative-infinity (-1.0 / 0.0) EO objects here.

Is it possible to implement it?

number.eo:292-294: Remove unnecessary checks and move...

The puzzle 53-64d5b423 from #53 has to be resolved:

# @todo #53:30min. Remove unnecessary checks and move some of them to ln
# when ln is implemented in EO and Double.NaN, Double.POSITIVE_INFINITY,
# Double.NEGATIVE_INFINITY are converted to eolang objects.

The puzzle was created by @rultor on 07-Nov-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Calculate series atom

What if we introduce a new atom that calculates a series. So we could implement sin, cos and and othe trigonometric functions via Taylor series. It would take a value and formula for coefficient of nth term. For example we could implement exp(x) by this:

[x] > exp
  calc-series > @
    x
    "1/n!"

We need to give coefficient of nth term somehow.
@Graur @EugeneDar @includealex what do you think?

Integrals

We can now implement integrals using Simpson's rules:
$$\int_a^b f(x) dx \approx \frac {b - a}{6} \cdot [f(a) + 4f (\frac{a + b}{2}) + f(b)]$$
or
$$\int_ a^b f(x) dx \approx \frac{b-a}{8} \cdot [f(a) + 3f (\frac{2a + b}{3}) + 3f(\frac{a+b}{3}) + f(b)]$$

@Graur what do you think about having integral object in eo-math?

Binary search object

For creating new objects, for instance, arccos using binary search is needed. I think, that it would be helpful to have such an object as binary-search:

[localization-area precision given-value foo-to-use] > binary-search

Where

  • precision is an accuracy with what you want to count result
  • given-value is a value you want to count. For instance, arccos 0.6 here 0.6 is a given value
  • localization-area is an area where we are searching for function meaning. If we take arccos as an example, localization area would be $[0; \pi]$
  • foo-to-use is a function we use to count out and compare with precision
    @yegor256 @Graur what do you think about it?

arccos object

I think that we should have an opportunity to count arccos of some value. It can help in implementation Chebyshev Polynomials. For instance, we will have an ability to count them like
$$T_n(x) = \cos {(n \cdot \arccos{(x)})}$$
@Graur what do you think? Do we need object acos in eo-math or it would be better to avoid having it?

number.eo:183-184: min. Add an ability to raise a number...

The puzzle 21-dd9dd514 from #21 has to be resolved:

# @todo #21:30 min. Add an ability to raise a number to float power.
# `exp` and `ln` objects are needed. sqr(n,x) = exp(n * ln(x))

The puzzle was created by maximtrunnikov on 19-Sep-22.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

rultor merge failed

When I'm trying to merge some changes with rultor, I've get an error.

Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: EOorg/EOeolang/EOmath/EOnan$EOas_int$EO?.java
    at sun.nio.fs.UnixPath.encode (UnixPath.java:145)
    at sun.nio.fs.UnixPath.<init> (UnixPath.java:69)
    at sun.nio.fs.UnixFileSystem.getPath (UnixFileSystem.java:279)
    at java.nio.file.Path.resolve (Path.java:515)
    at org.eolang.maven.Place.make (Place.java:61)
    at org.eolang.maven.JavaFiles.saveJava (JavaFiles.java:96)
    at org.eolang.maven.JavaFiles.save (JavaFiles.java:77)
    at org.eolang.maven.TranspileMojo.exec (TranspileMojo.java:141)
    at org.eolang.maven.SafeMojo.execute (SafeMojo.java:112)

I think rultor.yml configuration merge is broken

number.eo:303-305: min. Implement exp using this taylor...

The puzzle 56-a1660657 from #56 has to be resolved:

# @todo #56:90 min. Implement exp using this taylor object.
# You need to code a function for coefficient of nth term.
# Accuracy can be decreased because of stack limitation.

The puzzle was created by levBagryansky on 10-Nov-22.

Estimate: 90 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.