Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
How would I write the following arithmetic expression in Prolog?
sqrt(9*log10(X)/5,9) * (1-(2X*sqrt(X)/5))^(2/7)
The square root is using the 9th root.
There is some variation between Prolog implementations, but I can promise you the following:
2X isn't going to work anywhere, except maybe a computer algebra system.
sqrt means square root. If you want to take the 9th root, you have to use a fractional exponent, such as X ** (1/9).
ISO intends ^ for integer exponentiation and ** for floating point exponentiation. Obviously, 2/7 is not an integer.
The expression you probably want is, therefore, this:
Y is (9 * log10(X) / 5) ** (1/9) * (1 - (2 * X * sqrt(X) / 5)) ** (2/7).
Notice my liberal use of whitespace. It's free, after all.
I get a lot of undefined errors for various inputs with this because you cannot take a negative number to a fractional power. I suspect this means one of us has a precedence error that can only be resolved by someone who knows what this formula is for and can compare to the original.
In the future, it would be a good idea augment your question with A) things you have tried, and B) what exactly your problem is. This question looks a lot like "do my work for me" which is probably why it's being downvoted.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
implemented a solution to a problem in arithmetic precision handeling in gmp - but the results are rather strange . as a part of troubleshooting I was wondering whether there is any other package hich woudl allow similar operatiosn as gmp in R. I would need something like chooseZ and multiplication of numbers larger than 2^64 - jsu to make sure that I am not having an error somewhere in this step of my script
need to compute nubers like
choose(2450,765) then multiply it with a floating point number like 0.0034
the log solution is not really working becasue the expression can aslo be
sum for 2 to k of (k* k*choose(1800,800)*0.089)
so Iw ould need a wauy to sum over (k kchoose(1800,800)*0.089)
You could just work on the logarithmic scale:
lchoose(2450,765) + log(0.0034)
#[1] 1511.433
If you exponentiate this, you get a really big number. I simply do not believe that this number would be different from Inf for any practical purpose and I believe even less that you'd need it to exact precision.
Edit:
If you want to calculate \sum_{i=2}^k{i^2 * choose(1800, 800) * 0.089}, you should see that this is the same as choose(1800, 800) * \sum_{i=2}^k{i^2 * 0.089} and then you can again work on the logarithmic scale.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I am reading a review to compare Mathematica to APL/J. One question raised in the article seems very interesting to me:
Is Mathematica really the way to go to express our creative thoughts –
viz back to a 17th century notation designed for parchment instead of
forward to a twentieth-century one designed for computers?
Can one share examples of Iverson's notation vs traditional math notation to demonstrate the edge of APL/J on expressing and solving math problems? This would be greatly helpful for new comers.
One example: Alternating series.
Alternating sum is very common in mathematics. But it is cumbersome to put the sign before each term:
in APL and J, because of the order of operations, it is
-/a
I recommend reading Iverson's paper Notation as a Tool of Thought, kindly provided by the J folks. It deals precisely with this issue.
In it you'll find many Math proofs derived using APL instead of the classical notation, along with accompanying commentary. Here's a redacted example, proving Gauss's formula for the arithmetic series:
+/⍳n
+/⌽⍳n ⍝ as + is associative and commutative
((+/⍳n)+(+/⌽⍳n))÷2 ⍝ as x=(x+x)÷2
(+/(⍳n)+(⌽⍳n))÷2 ⍝ as + is associative and commutative
(+/(n/n+1))÷2 ⍝ summing each respective x∊⍳n and y∊⌽⍳n, y=n+1-x → (x+y)=n+1
(n×n+1)÷2 ⍝ per definition of × (times)
Other articles by Iverson, Hui and friends are also illuminating. Again, the J folks provide a notable library.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
For my theory of computation class, we are supposed to do some review/practice problems to work off the rust and make sure we are ready for the course. Some of the problems are induction proofs. I did this at one time, but apparently it has completely escaped me. I've watched a couple tutorials, but still can't do problem 'a'. If anyone can walk me through the first problem I'm pretty sure I could figure out the second one on my own. Any help would be appreciated!
First verify it holds for n = 1.
Then assume it is true for n = x ( the sum of the first x squares ) and then try to compute the sum of the the first x + 1 squares. You know the result for the first x, you just add the last square to that sum. From there it should be easy.
And you posted on the wrong site.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Well is it possible to find private key x for this equation y=g^x mod p of course big integers if you have p ,g, y, q?.
What method can be used if there is method to find it out? ..........Note:These are big Integers
This is called the discrete logarithm problem. You seem to be interested in the prime field special case of this problem.
For properly chosen fields with sufficiently large p this is infeasible. I expect this to be reasonably cheap (100$ or so) for 512 bit p and extremely expensive at 1024 bit p. Going beyond that it quicky becomes infeasible even for state level adversaries.
For some fields it's much cheaper. For example solving DL in binary fields (not prime fields as in your example) produced quite a few recent papers. For example Discrete logarithm in GF(2^809) with FFS and On the Function Field Sieve and the Impact of Higher Splitting Probabilities: Application to Discrete Logarithms in F_2^1971.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Which is more random?
rand()
OR
rand() + rand()
OR
rand() * rand()
Just how can one determine this? I mean. This is really puzzling me! One feels that they may all be equally random, but how can one be absolutely sure?!
Anyone?
The concept of being "more random" doesn't really make sense. Your three methods give different distributions of random numbers. I can illustrate this in Matlab. First define a function f that, when called, gives you an array of 10,000 random numbers:
f = #() rand(10000,1);
Now look at the distribution of your three methods.
Your first method, hist(f()) gives a uniform distribution:
Your second method hist(f() + f()) gives a distribution which is peaked in the centre:
Your third method hist(f() .* f()) gives a distribution where numbers close to zero are more likely:
As to amount of entropy, I guess, is comparable.
If you need more entropy (randomness) than you have currently have, use cryptographically strong random generators.
Why they are comparable --- because if attacker could guess next pseudorandom value returned by
rand()
it would not be significally harder for him to guess next
rand()*rand()
Nevertheless argument about different distributions is important and valid!