You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
-0.2 is not zero to return a division by zero error.
The function returns -nan, i.e. Not a Number. and the error is thrown when trying to divide by -nan. If anything, the error text is just not appropriate.
Correct solution: solution is in the complex domain.
But if we are talking about having different branches of solutions for positive and negative input parameters, we just need to define these branches first:
.
Make such a feature and you'll be fine. ;)The function returns -nan, i.e. Not a Number. and an error is thrown when trying to divide by -nan. If anything, the error text is just not appropriate.
Why on earth would -0.2 be -nan ?)
Another test function
In calculator.
In mql functions
So why the hell is -0.2 a nan?)
Another test function
In a calculator
In an mql function.
is not -0.2 - nan, but the result of a degree increase.
The fractional degree of a number (a^m/n) is the root of degree n of a^m.
If the sub-root value is negative, it can be either negative or positive, based on the power of m and the number a itself (which in my problem is always negative, so it is positive for positive power of m and negative for negative). So if the sub-root value is negative, then the number is also negative. The root of a negative number lies in the complex area, so we can't operate on values of the complex area viathe usualdouble type, which is why the standard implementation of degree gives -nan.
Correct solution: the solution is in the complex domain.
But if we are talking about having different branches of solutions for positive and negative input parameters, then we just need to define these branches first:
.
Make such a feature and you'll be fine. ;)Thank you for your detailed answer. But for me complex calculus is not suitable for my problem, so most likely I will limit myself to natural numbers and as a result I will not fall into the complex domain.
Thank you for your detailed reply. But for me the complex calculus is not suitable for my problem, so I will most likely limit myself to natural numbers and as a result will not fall into the complex area.
That's what I'm talking about, and I specifically showed you an example. Look at it carefully. This example is exactly for your case.
zy
translating to µl is very easy
is not -0.2 - nan, but the result of a degree.
The power of a fractional number (a^m/n) is the root of degree n of a^m.
If the sub-root value is negative, it can be either negative or positive based on the power of m and the number a itself (which in my problem is always negative, so it is positive at positive power of m and negative at negative). So if the sub-root value is negative, then the number is also negative. The root of a negative number lies in the complex area, so we can't operate on values of the complex area via the usual double type, which is why the standard implementation of the degree gives -nan.
Andrey, yes, I misspoke, it is clear that the result of raising to a power returns -nan.
But this result gives rise to a fractional powers, where the integer is zero -0.2
The calculator calculates everything correctly.
And the previous test, too, does not count as in the calculator.
That's what I'm talking about, and I specifically gave you an example. Take a good look.
Yes, I got it. Thank you. (even the formula is written down)
Perhaps the legs grow from the fact that you can't take an even root from a negative number ? I'm already a bit confused... And most importantly how to get around it ?
Whole degrees are determined simply by multiplication (and taking the inverse for negative exponents), so are easily transferred to negative bases. Fractional degrees are defined via logarithm and exponent: y^x=exp(x*ln(y)) and with negative numbers come to the complex plane. The logarithm has an infinite number of branches and to avoid the hassle of finding the right branch, they return NAN.
Thank you for your answer, but in general if we take an arithmetically correct solution, it seems that only complex numbers can be used to implement such a solution... In your proposed method it is necessary to split the degree so that the underlying value always has a positive degree and the answer will always be positive. But if you take without this fitting - we come only to complex numbers, in fact according to generally accepted algebraic model as I know (I'm not a mathematician by education) - the root of a negative number will be a complex number.
use the formula I suggested above.
Here's the same formula:
and here is an example of how to convert a double into a fraction
https://www.mql5.com/ru/forum/290279#comment_9396706