484 questions
1
vote
2
answers
104
views
How to check if variable is infinite in sympy
Sympy has (at least?) three types of infinity (infinity, negative infinity, and complex infinity). I have come across the problem of testing if a sympy expression is infinite and my program failed ...
4
votes
1
answer
153
views
In Haskell, why toRational (1/0) == infinity is False?
I couldn't find documentation for this behaviour and it looks like a bug ([Edit] it is indeed : gitlab.haskell.org/ghc/ghc/-/issues/10387). Am I missing something ?
In GHCi :
> import GHC.Real
...
0
votes
1
answer
63
views
how to keep the value up and organize the cycle correctly?
I have this code:
import java.util.List; import java.util.Scanner;
public class AddElementsInLists {
private static final Object lock1 = new Object();
private static final Object lock2 = new ...
2
votes
3
answers
124
views
Raising a float near 1 to an infinite power in Python
1.000000000000001 ** float('inf') == float('inf')
while
1.0000000000000001 ** float('inf') == 1.0
What determines the exact threshold here? It seems to be an issue of float precision, where numbers ...
1
vote
1
answer
118
views
Infinite Marquee with gradient text
I need to make an endless running line with gradient text that changes as it moves, as in the example, it works, but there are problems in Safari, everything twitches there and the letters seem to run ...
0
votes
1
answer
107
views
ADF Copy activity is making double column in adx as "infinity" for 1.7976931348623157E308 value
We are trying to convert the delta into adx in which we have delta column double type and data in it is "1.7976931348623157E308" which is double max value, and using copy activity we need to ...
0
votes
1
answer
1k
views
Grafana Infinity Datasource
How to allow all hosts for infinity datasource in grafana. my json for config map of datasource is
kubectl describe configmap grafana-app-config-datasource -n grafana
Name: grafana-app-config-...
1
vote
1
answer
170
views
Why does `upper_inf` return false when the range uses `infinity` as an explicit upper boundary?
PostgreSQL range docs suggest that the magic timestamp infinity should work the same as omitting the bounding value:
Element types that have the notion of “infinity” can use them as explicit bound ...
2
votes
1
answer
168
views
Pytorch Conv2d outputs infinity
My input x is a [1,256,60,120] shaped tensor. My Conv2d is defined as follows
import torch.nn as nn
conv2d = nn.Conv2d(
256,
256,
kernel_size=2,
stride=...
-1
votes
1
answer
111
views
C and infinity arithmetic
#include <math.h>
void main() {
double a = 0;
a += 5e308;
a -= 3.5e308;
if (a == INFINITY) {
printf("1 %e\n", a);
}
else
printf("0 %e\...
2
votes
1
answer
163
views
Can a c++ compiler implement floating-point numbers using projective infinity?
This question is inspired by this question about negative infinity and this other question about the total ordering of floating point numbers.
It is motivated by my impression that, given some ...
5
votes
1
answer
182
views
complex("inf") ** 1 throws OverflowError
In Python 3.10.9, this example raises OverflowError: complex exponentiation:
complex("inf") ** 1
But this works, evaluating to (nan+nanj):
complex("inf") ** 2
Why does it work ...
4
votes
1
answer
7k
views
Ways to represent float infinity in C++
I want to express floating-point infinity in C++ for my program.
I came across two ways to achieve this: using INFINITY and std::numeric_limits<float>::infinity().
Both options seem to work, but ...
0
votes
0
answers
120
views
Use QString::arg(double a) with std::numeric_limits<double>::infinity()
I am trying to convert floating point values to their string representation, using the QString class from the Qt framework. To do this, I am using the following function:
QString QString::arg(double a)...
2
votes
1
answer
4k
views
Title: Creating an infinite logo slider using React and CSS without third-party libraries
I'm working on implementing a logo slider in my React application using CSS. I want the slider to behave as an infinite loop, where the last logo in the slide is followed by the first logo, and this ...
0
votes
0
answers
532
views
Error in seq.default(min(x), max(x), length = evaluation) : 'from' must be a finite number, when using scatterplotMatrix function
I am trying to plot my data using scatterplotMatrix, to draw scatter plots depend on different ID.
Yet I got an error:
seq.default(min(x), max(x), length = evaluation) : 'from' must be a finite ...
5
votes
3
answers
26k
views
How to use .env file in Nuxt 3
Am using Nuxt-3 as my framework for the project and am very new to the framework too and when I was integrating api for my project and I was getting the response later when I tried to use api as ...
2
votes
0
answers
105
views
std::isinf doesn't work when the program is run with valgrind
I have this simple program:
test.cc:
#include <limits>
#include <iostream>
#include <cmath>
int main() {
std::cout << (std::isinf(std::numeric_limits<long double>::...
1
vote
1
answer
164
views
Is there a difference between math.inf and cmath.inf in Python?
Is there any difference between the infinities returned by the math module and cmath module?
Does the complex infinity have an imaginary component of 0?
0
votes
2
answers
92
views
Why is -math.inf and math.inf added to this minimax algorithm, if these starting values be replaced with the highest and lowest score later?
as you can see this is the code for an unbeatable AI TicTacToe game(game.py is the main file):
game.py
import math
import random
class Player():
def __init__(self, letter):
self.letter = ...
0
votes
1
answer
244
views
For-loop returning wrong results
I am getting wrong results resolving below task:
Generalized harmonic numbers. Write a program GeneralizedHarmonic.java that takes two integer command-line arguments n and r and uses a for loop to ...
6
votes
2
answers
196
views
Why addition error near `DBL_MAX` and infinity?
In experimenting with rounding modes, FE_DOWNWARD ( and FE_TOWARDZERO) apparently fails to form the expected sum of infinity and instead forms DBL_MAX when adding DBL_MAX and 1 ULP of DBL_MAX.
Follows ...
3
votes
2
answers
1k
views
Floating point multiplication results in infinity even though rounding to nearest
Consider the following C++ code:
#include <fenv.h>
#include <iostream>
using namespace std;
int main(){
fesetround(FE_TONEAREST);
double a = 0x1.efc7f0001p+376;
double b = -...
0
votes
1
answer
611
views
Automatic Speech Recognition CTC Loss Suddenly Goes to Infinity After 100 Batches
I have been struggling to create a automatic speech recognition neural network using tensorflow trained on the hugging face mozilla common voice 11 dataset. The model seems to train well for around ...
1
vote
1
answer
106
views
in R, why does as.Date(Inf) display as NA, yet fails the test for being NA
An alternative title to this question is:
When is an NA date not an NA?
Answer: when it is infinity formatted as a date.
Converting infinity to a date results in NA being displayed, but it is not!
>...
1
vote
1
answer
433
views
Correct way to check if a variable is HUGE_VAL in C
I have a variable in C which can contain the values HUGE_VAL or -HUGE_VAL. I can see there exists a function called isfinite() complying with C99, which is the standard I use. But according to the man ...
56
votes
3
answers
4k
views
Why is log(inf + inf j) equal to (inf + 0.785398 j), In C++/Python/NumPy?
I've been finding a strange behaviour of log functions in C++ and numpy about the behaviour of log function handling complex infinite numbers. Specifically, log(inf + inf * 1j) equals (inf + 0.785398j)...
1
vote
2
answers
419
views
Why does `np.sum([-np.Inf, +np.Inf])` warn about "invalid value encountered in reduce"
python -c "import numpy as np; print(np.sum([-np.Inf, +np.Inf]))"
gives
numpy\core\fromnumeric.py:86: RuntimeWarning: invalid value encountered in reduce
return ufunc.reduce(obj, axis, ...
0
votes
2
answers
94
views
unprecise math in R when dealing with infinite fractions
The deviations of the mean should always sum up to 0.
However, when the mean has a lot of digits, maybe infinitely like this one which is 20/7, R fails to calculate it.
x <- c(1,2,2,3,3,4,5)
sum(x -...
1
vote
0
answers
698
views
what to do when isinf() and isfinite() are not working?
If I compile my program with -Ofast with clang, sometimes I will get an infinite float back, but isinf() and isfinite() don't work. U is a floating-point type, I (>=0) and wbits (>0) are ...
1
vote
0
answers
226
views
sympy: How to simplify this expression
with sympy I solved an equation for a parameter (x1 in this case) and then substituted another parameter c2 by 0 (in the real solution).
import sympy as sp
c1, c2, x1, F_C = sp.symbols("c1, c2, ...
2
votes
1
answer
630
views
Avoiding NaN and Inf when computing exponential in Matlab
Suppose I have a vector S and am interested in computing the value ln(1+exp(S)) or ln(1+exp(-S)).
However, if an entry is too large or too small, I will encounter Inf problems or other numerical ...
-1
votes
1
answer
728
views
Why does my code return NAN and Infinity?
I'm trying to make a simple BMI calculator. However, if I just hit the calculate button, after the alert it renders the NAN as a 'result'. And if I just input the weight, it returns an Infinity ...
1
vote
1
answer
102
views
"Infinity" if I don't pass any number as parameters
Having this issue most likely I am doing everything wrong, but I wanted to find the smallest and the biggest number inside an array and return it to a new object, and if this array is empty I wanted ...
0
votes
1
answer
125
views
Minus infinity in Python as a result of for loop?
I am trying to calculate valocity in Python with for loop. But when I run my code, I get "-inf" as a result for every row.
This is my code:
Vx = 0
for i in range(1, len(x_axis.timestamp)):
...
0
votes
2
answers
271
views
Logarithm of a random number
I wrote a fortran program to code this algorithm (https://en.wikipedia.org/wiki/Reservoir_sampling#Algorithm_A-ExpJ). It works on my computer. But after I asked these two questions (Intrinsic Rand, ...
0
votes
0
answers
86
views
How far can we trust calculus with infinity?
In this simple calculus, all the results are OK :
program main
real :: x,y,z
x=0.0
y=1/x; print *,y
y=log(x); print *,y
z=0.99; y=z**(1/x); print *,y
z=1.0; y=z**(1/x); ...
3
votes
2
answers
1k
views
max returns negative infinity in R
I have stumbled upon a seemingly simple problem which I just cannot solve. I am attempting to use max and which on a vector that does not contain the value of interest. Ideally I would like to ...
0
votes
2
answers
4k
views
How to coerce math.Inf to an integer?
I've got some code I'm using to do comparisons, and I want to start with infinite values. Here's a snippet of my code.
import (
"fmt"
"math"
)
func snippet(arr []int) {
...
4
votes
3
answers
2k
views
Select rows with any infinite value (Inf or -Inf)
How do I subset rows from a data frame which have at least one infinite value (Inf or -Inf)?
Here is an example data frame:
my_data <- data.frame(column1 = c(Inf, 5, 3,4,5),
...
1
vote
1
answer
338
views
Numpy SVD gives infinite singular values for array with finite elements
I've run into this problem (infinite singular values despite finite entries in an array) several times for relatively small arrays with dimensions around 100 by 100. The arrays are large enough that I'...
2
votes
0
answers
137
views
Why does numpy floor_divide with infinity differ from true_divide
numpy's floor division seems counterintuitive when dealing with np.inf. I feel like the answer should be same as true division in these examples
>>> -7 // np.inf
-1.0
>>> -7 / np....
0
votes
1
answer
126
views
Possible bug with inf or too large values?
I'm trying to train a neural network with keras and tesorflow. As usual, I replace -np.inf and np.inf values with np.nan to later run a dropna sequence and clear all that wrong data such as:
Data....
1
vote
1
answer
145
views
IEEE 754-2008 Float32 calculations incorrect in HDL simulators
If I try to use calculations with infinity results (in float32 representation) there are some unexpected results, as if the calculations were in double precision.
Simple casts to shortreal doesn't ...
0
votes
0
answers
36
views
by tracking its Infinity Recursive- JAVA basic q -, cant understand why its not recursive and how i tried to track this
public static int sod2(int x) {
if(x<10)
return 0;
return sod2(x/10)*10 + (x%10);
}
}
I can not understand how its not infinity recursive, tried some different numbers and ...
2
votes
2
answers
2k
views
Enable OAuth2.0 in Grafana Infinity plugin for Citrix data source
I am trying to collect data from REST API using Grafana plug-ins (Infinity, Simple JSON, JSON), The problem is in order to access the API you should maintain a valid OAuth Token which expires every ...
1
vote
1
answer
382
views
Ruby exponentiation warning for large numbers
I am working on a problem in Ruby. The function called last_digit takes in two integers. The first integer is then raised to the power of the second integer. The function must return the last digit of ...
0
votes
0
answers
138
views
javaScript - Disable Number.MAX_SAFE_INTEGER [duplicate]
I created a component to calculate the power of numbers
but the problem is Number.MAX_SAFE_INTEGER.
how can I calculate a larger number like 5^200 in my app completely without rounding?
Math.pow(5,200)...
1
vote
0
answers
61
views
How to make the main ground generate infinity
Hello I am a beginner in unity 3D and I want to create a game where a ball rolls on the ground and you need to doge the obstacles but I don't know how to create the ground generate infinity and I also ...
3
votes
2
answers
1k
views
How do I select floating-point infinity literals from a SQLite database?
I have a SQLite database with a table named measurements, which contains some experimental data measured by a power meter. They're stored as data type REAL in a field named power_dbm. In some ...