The tag has no usage guidance.

learn more… | top users | synonyms

0
votes
1answer
37 views

negative values are being treated as positive in RHEL suddenly. Why?

For example: # [[ -24 > 0 ]] && echo "Hi" Hi Since yesterday, I found this weird behavior. What could be the reason?
0
votes
1answer
121 views

Why does the factor command produce nonsense on an RSA modulus?

Ok, so I think I may have found a flaw in... something. I honestly don't know. This is such a weird scenario. I was attempting to break very small asymmetric (RSA) encryption, just as a Proof of ...
0
votes
0answers
11 views

How to Do Trigonometric Range of Floats in Python? [migrated]

Matlab x = 0:pi/100:2*pi; y = sin(x); plot(y) I think range() cannot work here because it only accepts end arguments as integers but I need floats (0.0; 2*pi). Pseudocode in Python 2.7.11+ import ...
2
votes
2answers
70 views

Equation solver for the shell?

Is there an equation solver for the shell? For example, I enter input 1000=x^(1.02) and the shell solves for x.
0
votes
0answers
16 views

How do I compute the angle of the 2D 3 points ? [[ In kernel space]

I 'm looking at the touch driver 's Kennel. Sometimes a touch is bouncing County singah appear. Collected by recruiting three points 'm trying to calculate the angle between . But there is no such ...
1
vote
1answer
21 views

Mean and variance of words pronounced

I'm working on linguistics and am trying to calculate the average sentence length and how much this average varies. I worked to leave always one sentence per line For instance: La dernière fois ...
3
votes
2answers
275 views

How can I do basic calculations in a shell script?

I want to perform some mathematical operations in the shelll. For example: 5+50*3/20 + (19*2)/7 I tried: #!/bin/bash read equ echo "scale=3; $equ" | bc -l Expected output: 17.929 My ...
3
votes
3answers
63 views

A bc problem about long expression

I want to calculate an expression in shell. I use the following code: pi=$(echo "scale=10; 4*a(1)" | bc -l) i=3 d=`expr (1+c($pi*($i/10)+$pi))/2 | bc -l` But it says bad pattern: (1+c(3.1415926532*...
0
votes
1answer
26 views

Maths revision program [closed]

I have created a program that will randomly select two numbers out of a range and ask a multiplication question from it. It works well but as I am new too coding it looks very messy and repetitive. I ...
6
votes
3answers
568 views

Weird float rounding behavior with printf

I've read some answers on this site and found the printf rounding desirable. However when I used it in practice, a subtle bug led me to the following behavior: $ echo 197.5 | xargs printf '%.0f' 198 ...
1
vote
0answers
18 views

How do I use octave to find the numerical solutions to a system of non-linear equations?

I have the following set of equations: acos(x/250)=t acos(w/300)=u asin(y/250)=u asin(z/300)=t w-x=150 z-y=150 How do I solve this system of non-linear equations using octave? The only ...
1
vote
2answers
179 views

How to add all values in an array

I have been stuck on this for way to long now. Tried googling and couldn't find what I was looking for. I simply need to add all the values in an array.(array called packets) I have gotten to the ...
1
vote
4answers
546 views

bash division of numbers in text file

I have two numbers in test.txt file, I would like a way to divide the second number by the first number and assign the result to a variable or file in a bash script that I can use. I have used awk "NR=...
0
votes
1answer
274 views

How do I add integer and floating numbers together to keep tally?

I'm just trying to do some simple math that is not turning out that simple. this is what I have tried so far and I have yet to find anything on the google net that combines integer and floating ...
26
votes
20answers
8k views

How do I print pi (3.14159)? [closed]

What command could print pi for me? I want to specify how many digits it prints, I couldn't find anything online. I just want to be able to print pi.
2
votes
1answer
112 views

Mathematical processing on text file

I have 200 text files. Each text file contains one column of mathematical numbers (100k rows). I want to do some statistical processing on these data (finding the probit or quantile). I know the ...
5
votes
3answers
639 views

Increment numbers inside strings by an offset

I want to search a text file for strings like these. [task0] [task1] ... [task1613] and increment each by a given offset, in this case by 3640. So, with the example I gave above, I'd get the ...
6
votes
5answers
360 views

Command line expression solver?

I'm looking for a Linux-compatible TTY-based calculator. For example: user@host:~$ calculate > 2 2 user@host:~$ calculate > 8*6-4 44 user@host:~$ calculate > 8*(6-4) 16 Is there anything ...
3
votes
1answer
2k views

basic division using variable and integer

I'm an extreme beginner in bash commands, and am having trouble figuring out a basic division command. count = redis-cli llen domains; echo $count returns 1000 How can I echo $count/1000? I've ...
3
votes
3answers
82 views

Script is stuck saying 1 response with 2 available: Math related

I have a script that tells the user the square footage of 2 rooms based on user input. I think I have that part done right. The problem I have is that I need to have the script say which room is ...
3
votes
1answer
43 views

How to calculate (weighted) majority over columns?

I have two files: the first one contains lines where the first column is an ID, and the remaining columns are votes, e.g. 3242 -1 1 -1 1 1 1 In a first step I want to calculate the majority for ...
4
votes
2answers
776 views

How can I round all numbers in a file?

How can I round all numbers in a file that countains several columns of numbers up to a certain precision? Can this be done with awk? A single line looks like this: text - 0.1655456615 - 0.158645 - ...
2
votes
2answers
3k views

How to sum a bash array of numbers (some in scientific notation)?

Since the following command using bc does not work for numbers in scientific notation, I was wondering about an alternative, e.g. using awk? sum=$( IFS="+"; bc <<< "${arrValues[*]}" )
0
votes
1answer
470 views

expr command used to work and stopped

I am on SunOS machine trying to get the date string of the past minute, yesterday I used this command I found on the internet expr `date +%Y%m%d%k%M` - 1 which is worked just fine and I saw the ...
3
votes
4answers
1k views

Round/truncate digit in string in zsh (or with external tool)

I'm trying to do an interface to bc so it can be used intuitively and without the annoyance of getting "stuck" in it. I haven't got around to test it that much, because I got stuck on another detail, ...
3
votes
2answers
306 views

How do I convert my old PC to a data logging and presentation terminal?

Take an old PC (e.g. 1.8GHz P4 with 256MB RAM), install e.g. Ubuntu 10.04 LTS on it. Now go to your PIC or AVR based home project and hook up the thing. With only three connections and the onboard ...
1
vote
3answers
170 views

how to type linear algebra symbols

How do I type the symbols for linear algebra on Ubuntu? Are there any programs that use them? ( I understand this is trivial basket weaving. Whats the fastest way! )
2
votes
1answer
189 views

Illustrate the difference of two squares via the command line

So, after 10 years of wanting to study the book that Ramanujan relied upon for a lot of his early strides in mathematics, it's 2012, and the book is finally online. To celebrate, I want to go through ...
28
votes
9answers
13k views

Addition with 'sed'

I am trying to perform a mathematical operation with sed, but it continues to treat my variables as strings. The input is of this kind: $ echo 12 | sed 's/[0-9]*/&+3/' $ 12+3 I'd like to have ...
0
votes
1answer
113 views

Why does octave give different results for 9 ^ 1/2 and 9 ^ 0.5?

Lately I've been trying to brush up on the math I should have learned in high school. (I didn't pay much attention.) Regarding this, college entrance exams and octave make a great pair. This morning ...
12
votes
4answers
4k views

Free Matlab equivalent for Linux

My collaborators are using Matlab to do some simulations. Is there an open source alternative I could use on Linux to run these scripts? It would need to be fairly closely compatible with the (1) ...