Questions tagged [exponent]
Exponentiation is a mathematical operation, written as b raised to the power of n, involving two numbers, the base b and the exponent (or power) n.
569
questions
-2
votes
1
answer
55
views
Why does 0 ^ 3 return 3 in java ? Shouldn't it be 0? [duplicate]
I’m writing a simple program and one of my first steps involves raising a number by 3.
public class ASum {
public static void main(String[] args) {
System.out.println(0 ^ 3);
}
}
...
-3
votes
0
answers
66
views
Zero Subsequences problem - What's wrong with my C++ solution?
Problem Statement:
Given an array arr of n integers, count the number of non-empty subsequences of the given array such that their product of maximum element and minimum element is zero. Since this ...
0
votes
2
answers
32
views
With only CSS can I make an element cover an entire DIV?
To make it more simple, i'm working on this site https://webdev02.amontagnana.it/ and on the 4th row we can see a text block and an embedded video.
I need to make the video's height just like the ...
0
votes
1
answer
22
views
NVD3 - Use superscript in axis label
TLDR: My NVD3 chart's Y-Axis label is "Molecular density (kg/m^3)" but I would like it instead to be "Molecular density (kg/m3)".
I am currently using NVD3 JavaScript library to ...
0
votes
1
answer
41
views
Solve equations for exponent in python
This code solves for the exponent in x^n + y^n - z^n = 0 by brute force. Would there be a faster and cleaner way to do this?
import math
for n in range(-10, 100000000):
n /= 1000000.0
x = ...
4
votes
1
answer
87
views
`x^(1/3)` behaves differently for negative scalar `x` and vector `x` with negative values [duplicate]
R seems pretty comfortable with computing the odd root of a negative number
-0.2^(1/3) # returns a good number
# [1] -0.5848035
but something weird happens if you raise a vector to the 1/3.
c(-0.2, ...
0
votes
2
answers
47
views
How do I square a column from an Excel file with pandas?
I've read an Excel file into python using:
import pandas as pd
import numpy as np
water_consumption = pd.read_csv('Self_Data.csv')
and I'm trying to square the columns using:
exponent = 2
...
0
votes
1
answer
84
views
Power to n implementation that produces wrong results for negative exponent
In the following (naive) implementation of a pow(x, n) method, ignoring completely any optimized approach, I find the following problem:
public double pow(double x, int n) {
boolean negative = n &...
1
vote
2
answers
97
views
What is the best way to compute very large exponents?
I'm new to Python, and I'm trying to solve a programming problem where I have to compute 5 to the nth power, and once I have that, I just have to output the last two digits of that number. This is the ...
0
votes
0
answers
13
views
IntelliJ Javascript debugger for big.js - show value it represents
I have big(10) for example (where big.js is helpful in dealing with the precision problems that JS numbers have). When I'm debugging in IntelliJ and hover over this it shows Big {s: 1, e: 1, ... ...
1
vote
1
answer
59
views
1e400 == 10**400 is False? [duplicate]
In Python, 1e400 evaluates to inf, but 10**400 prints out just fine. Theoretically, 1e(x) is supposed to be 10**x, but why and when does this break down?
In a related vein, 1e5 == 10**5 evaluates to ...
1
vote
1
answer
45
views
Negative exponent in division in Sympy
I make a division
fn=n/3**(n+1)
But the view has
fn=3**(-n-1)*n
Please tell me how to force as fn=n/3**(n+1)
0
votes
2
answers
167
views
Why my natural log function is so imprecise?
Firstly, I'm using this approximation of a natural log. Or look here (4.1.27) for a better representation of formula.
Here's my implementation:
constexpr double eps = 1e-12;
constexpr double my_exp(...
-4
votes
1
answer
68
views
Could anyone tell clearly how to find the exponents with fractional values or decimal values without using pre-defined function like <math.h>? [closed]
ex:2^0.5=1.414....&so want.
I'm newbie to c so please explain simple logic if not complicated logic is also enough
0
votes
2
answers
111
views
Override python built-in float() behavior
Old title: Convert scientific notation string without 'e' to float in Python
I use a program that has some ...odd formats allowed. One format for real numbers is scientific notation without the letter ...
0
votes
0
answers
13
views
Blank input line after user inputs even number to record all factors of 2
Essentially, the purpose of the program is to display all the factors of 2 within a number. It seems like I was getting close, until I tried to fix the 'jo' method to properly divide by assigning ...
0
votes
0
answers
58
views
Decimals ignored in numbers with Exponent
Why are my decimals ignored when I have e (Exponent) inside it? When I type 53e6, it gives the exact same result as 53.e6 (53000000). I would expect the output of the latter to be 53.000000 or just 53....
0
votes
0
answers
63
views
Using an Exponent in Excel SUMPRODUCT
I am trying to replicate the NPV of cashflows but with each cash flow using different interest rates.
The following code in excel continues to produce error values:
=SUMPRODUCT($A$4:$A$1347,($B$4:$B$...
0
votes
2
answers
544
views
how could I use the power function in c/c++ without pow(), functions, or recursion
I'm using a C++ compiler but writing code in C (if that helps)
There's a series of numbers
(-1^(a-1)/2a-1)B^(2a-1)
A and X are user defined... A must be positive, but X can be anything (+,-)...
to ...
0
votes
0
answers
44
views
How can I get 'return True' by exponent in JavaScript?
First, I'm sorry I can't speak English well.
I have some problems studying JS. I want to return true if the string is a Number.
If string is "0x10", "0b10", "9843" it ...
0
votes
2
answers
132
views
Why does the C++ array not work beyond the 4th element?
I am learning C++ and had an assignment that asked to take two numbers and insert them into an array. First number is the base number the second number was the array length. The length of the array ...
2
votes
3
answers
175
views
How to display exponent in a label? [duplicate]
I'm looking for a possibility to write a label text for cubic meters where the 3 is written as an exponent to m. For example:
mylabel.Text="m3";
Is it possible to write the 3 as an exponent?...
-1
votes
2
answers
154
views
Negative numbers with exponents in Python [duplicate]
Why does Python give me 2 different answers for the following?
print(-1**2) # prints -1
print((-1)**2) # prints 1
-3
votes
2
answers
114
views
without factorial function to do exponent approximation in python [closed]
Use loops to write a program that computes the value of by using the following formula.
e ^ x = 1+x/1!+x^2/2!+x^3/3!+ ...
Notice that do not import factorial function in math module.
Sample answers:e=...
1
vote
1
answer
352
views
Is modulo 10^9+7 useful in real world problems?
Take for example 5^100000
In competitive programming a constraint is given as we should compute under 10^9+7 I understand why they are using it (to prevent an overflow)
But my question is if the ...
0
votes
0
answers
52
views
Exponent values in Big query
It is percentage value 7.246353786042498E-8 for death percentage in covid cases i get after querying for only first few columns .How can I correct it in big query? Is it correct or wrong format?
6
votes
2
answers
3k
views
How do I raise X to the power of Y in Powershell?
I (apparently wrongly) assumed there would be a built-in power operator or function in Powershell, but I it seems there is not, or is there?
0
votes
0
answers
65
views
habit of pow(a, b) function in c++ (IDE Visual Studio 2019)
please, if somebody can explain. I have some questions about habit of pow(a, b) function in c++ (IDE Visual Studio 2019).
During exercises I found strange habit of x++ and ++x in library function pow(...
3
votes
1
answer
219
views
Raising an integer to a fractional power
I have the code:
(i as f64).powf(2.0 / 5.0).floor() as u64
Is there a way of raising an integer to a fractional power without resorting to floating point?
(I could performing two separate integer ...
0
votes
1
answer
81
views
How to get the correct diameter of a sphere given the volume
A few websites give the following equation for getting diameter from the volume of a sphere:
diameter = (6(V/pi))^1/3 i.e the cube root of 6(V/pi)
https://www.sensorsone.com/sphere-volume-to-diameter-...
0
votes
2
answers
72
views
multiple user input with their second input
I want the user's base input to be raised to the power the user input in the power.
def raise_power():
base = input("Base: ")
power = input("Power: ")
for index in ...
0
votes
0
answers
29
views
Not calculating exponential and log functions in Oracle
I am having some challenges with exponential and log functions in Oracle in that I am not getting the expected answer to the formula below -I should be getting 10.97 bur rather I am getting 32.77
The ...
0
votes
2
answers
55
views
unexpected behaviour when trying to do math in for loop
while trying to make simple code to convert hex to decimal:
#Hex multiply by 16 depending on position: 0xAB = A*16 + B = 10*16
#0x375
#3*(16**2) + 7*(16**1) + 5
i needed to reverse the ...
1
vote
2
answers
81
views
Powers of 10 not working correctly in Python: multiplying by 10**7 not returning the same as 10e7
I thought the syntax 10e7 is equivalent to 10**7.
However, I get the following odd output that I do not understand.
-8.555376292852173*(10**7)
returns
-85553762.92852174
And
-8.555376292852173*(10e7)...
0
votes
1
answer
60
views
Error in precision of python math.log(x,base) result
Python math.log(x,base) functionality is giving a minute error in the result which is breaking my functionality. I am trying to solve a problem where I need to get the index till which a number can go ...
5
votes
2
answers
164
views
Why does the multiplicative inverse of 0 result in infinity?
I am writing a program in Swift that takes the multiplicative inverse of random bytes. Sometimes, the byte is 0, and when the multiplicative inverse is taken, it results in inf.
The multiplicative ...
0
votes
0
answers
31
views
Write exponents as superscripts
consider the following list of numbers in R
list_num<-c(1,10, 100, NA, 0.1)
Can this be printed in this format
The printing should be as if they are numbers so that we can sort the same. I ...
1
vote
1
answer
98
views
Objective-c / Is it possible to encrypt rsa using modulus and exponent without external library?
Today, I implemented rsa encryption logic using openssl. Is it possible without an external library like openssl? Using a public key made of modulus and exponent.
My source is roughly like this.
-(...
0
votes
1
answer
118
views
How to get mantissa and exponent value separately
I have seen similar questions but still haven't found the answer to my problem. What I need to do is, I have a String array:
private String[] scientificNumberData = "2e3, 2e4, 6e3".split(&...
-2
votes
2
answers
58
views
Having trouble writing an equation with scientific notation and exponents in Python
I am having some trouble writing this equation in Python and having it produce correct results:
y = 2.95710^-7 * x^4 – 2.34310^-5 * x^3 – 1.67*10^-4 * x^2 + 0.04938 * x – 1.083.
I have tried the ...
2
votes
0
answers
40
views
(wx) Maxima: redefining tex used for parentheses, when an exponent is applied
This question explains how to set the tex output for a function to be handled analogously to powers on trigonometric functions; however, I was wondering how it would have to be modified if one wanted ...
2
votes
1
answer
108
views
Variable as an exponent in a string (Octave)
For an exercise i have to create an animated plot of the functions x^i from i=1 to i=10 in octave. The plot has to have a dynamic title and the color of the curves must change. Currently my code is ...
0
votes
0
answers
91
views
How to calculate e to the power of a matrix in R
Just a quick question: how to calculate e to the power of a matrix in R:
#the matrix
mm <- matrix(c(-0.447, 0.043, 0.232,-0.117), ncol=2)
#is this right?
exp(mm)
Any help will be greatly ...
0
votes
1
answer
277
views
Exponential number formatter - javascript
I was looking for a good way to format exponential values that satisfies all of the following...
Works in HTML <canvas> elements
Has a configurable base value (i.e. 10, 2, e)
Shows the exponent ...
3
votes
1
answer
95
views
Algorithm to precisely compare two exponentiations for very large integers (order of 1 billion)
We want to compare a^b to c^d, and tell if the first is smaller, greater, or equal (where ^ denotes exponentiation).
Obviously, for very large numbers, we cannot explicitely compute these values.
The ...
0
votes
1
answer
54
views
Log and exponent conversion in Big Oh notation
I'm doing some basic Big-oh problems in class and when reading the answer key, I'm having trouble understanding these log conversions that my professor did. I'd appreciate it if someone could write ...
-2
votes
1
answer
158
views
How to take an arbitrary power of a negative number
When trying to raise a negative number (e.g. np.sin(5)) to an arbitrary power of magnitude less than 1 (e.g. 1/3), it results in an error even when using np.power. But why is this and how can it be ...
1
vote
1
answer
95
views
Efficient way for checking number 3^x * 5^y
I want to check if number, based on lower and upper bound, has prime divisors only 3 and 5 and number should be multiplication of power of 3 and power of 5. My current solution is this. I want to ...
1
vote
0
answers
64
views
** Operator Causing RuntimeWarning: invalid value encountered in double_scalars
In a program I'm running, I have an issue where the exponent (**) operator in python is throwing a "RuntimeWarning: invalid value encountered in double_scalars" error, and I have no idea why....
0
votes
1
answer
152
views
Why my C# Code isn't Printing the Required Output
I attempting to create a program that uses multiple methods that would print out base numbers, exponents, and their resulting solutions. I am trying to get it to run and it's nearly completed, but I ...