Skip to main content

Questions tagged [math]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
30 views

Cartesian application software recommendation in Debian [closed]

Is there a software recommendation for an application for the Cartesian field in Debian?
Darevil294's user avatar
-1 votes
1 answer
91 views

SpeedCrunch is Providing Slow Math Calculations

I'm having a performance issue with SpeedCrunch 0.12 in Debian 12: sudo apt install speedcrunch First of all, I love the UI of SpeedCrunch, as a calculator, but currently (for me) it is giving very ...
Lonnie Best's user avatar
  • 5,185
0 votes
2 answers
101 views

math problem or variable value problem im not sure

I am having an issue comparing epoch times. I'm really not sure what I'm doing wrong. I have been tasked with identifying and actioning files beyond and during certain date ranges. In this case, it's ...
Kevin Huntly's user avatar
0 votes
0 answers
51 views

After cpu time hits 8128 seconds my calculations stops

I'm new to Linux and for my bachelor thesis I'm using it in order to calculate properties of materials in physics, therefore heavy calculations are involved. I've noticed that whenever Cpu time hits ...
CoolerThanACooler's user avatar
0 votes
3 answers
263 views

arbitrary base conversion from base 10 using only builtins in bash

I'm trying to sort out a bash command to convert a number from base 10 to an arbitrary base, using a specified set of characters (for example, to base 26 using letters a-z, although that's not ...
Hate9's user avatar
  • 21
3 votes
4 answers
595 views

awk or perl to eval mathematical expressions in each line

I want a script to make awk to become an interactive mathematical calculator, to eval mathematical expressions given in each line. I.e., instead of constructing awk commands to calculate expressions ...
xpt's user avatar
  • 1,644
2 votes
1 answer
106 views

Galculator weird behavior

Why does galculator miscalculate 4000225165312/512 and gets 781293977.6? Note This is intended as a canonical question cautioning against the unreflected use of galculator 1.2.4. Please do not use it....
Artem S. Tashkinov's user avatar
2 votes
3 answers
134 views

Replacing math equations by result

What is the best way to replace, in a file, equations found using some predefined regex with the result. Let's say each equation formula is compatible with bc -l (basic calculator with float numbers ...
taalf's user avatar
  • 23
9 votes
3 answers
4k views

Linux bc defines PI as 99

I'm using bc in Ubuntu Linux. It has a pre-defined constant PI that's set to 99. Why does bc define PI to be 99 instead of 3.14159...?
Jim's user avatar
  • 91
-1 votes
1 answer
75 views

average of nth line from mutiple files into one average master file

I have 3 files which contain 8 lines of numerical values and text. I'm trying to take the average of each rows across all three files and print a new file with those averages. The three example files ...
Lucas Djeu's user avatar
3 votes
2 answers
13k views

How do you type a number with a bar symbol over it?

100 divided by 3 equals 33.3 bar. How can I put a bar symbol over the three like this: You'd think there would be 9 Unicode characters dedicated to this, but I couldn't find them.
Lonnie Best's user avatar
  • 5,185
10 votes
1 answer
901 views

Why 'let' exits with code 1 when calculation result equals to 0?

I came across this question whose author had dealt with problem caused by: let x=1-1 exits with code 1. According to bash manual: If the last expression evaluates to 0, let returns 1; otherwise 0 is ...
Alexander Blazhkov's user avatar
0 votes
1 answer
248 views

How do I convert these commands to work in a conky file?

What I am doing is working on a conky widget, and I am trying to get a voltage reading from the sensor chip on my motherboard to display it. I am getting a voltage reading and displaying it in the ...
SwervedOne's user avatar
0 votes
0 answers
188 views

Why integer division is faster than bitwise shift in shell?

I'm comparing performance of bash and dash (default sh in Xubuntu 18.04). I expect sh to be faster than bash I expect bitwise shift to be faster than division operator. However, I'm getting ...
Zeta.Investigator's user avatar
9 votes
1 answer
731 views

Who decided the bc math library will define sine cosine and arctangent?

If you load the bc math library you get the trig functions s() and c() and a() which are sine, cosine, and arctangent respectively. Why these three functions? I know why it's those three from the ...
Mike Pierce's user avatar
0 votes
1 answer
82 views

any program with can show maths steps for simplifying algebra

I am looking for a program in linux or even a library which can show maths steps for simplifying algebra expressions Example: simplify 2(3x+5) step1: 2*3x + 2*5 step2: 6x + 2*5 solution: 6x + 10
Santhosh's user avatar
  • 409
0 votes
1 answer
77 views

select data conversion based on value range

I have a text file with 3 columns of data. However at random times in the various files there is a change in the in the observed unit from ppn to ppb resulting in the need of a conversion factor and ...
stormctr2's user avatar
0 votes
1 answer
62 views

How to keep blank data or assign missing data when recompiuting data for unit shift

I have a series of data files with format below. I have a script to read just the data to the needed units (ppm to ppb) thus the *1000 of column $3. The issue which I am running into when awk runs and ...
stormctr2's user avatar
0 votes
1 answer
622 views

If a sum equals zero how can I get awk to print another known value to the file

I have a numerous files in which I extract the total number of records and total number of missing files in order to compute data averages. I have numerous files where the number of missing records ...
stormctr2's user avatar
1 vote
1 answer
165 views

bash: set the value from log as a variable [duplicate]

I have a log file consiste of 240 float digits in the following format: 5.4 5.1 5.2 5.4 5.4 4.9 5.0 5.2 5.5 5.3 5.6 5.4 5.1 5.3 5.3 5.1 5.2 .. 4.8 Accesing to this log file in bash environment I need ...
Hot JAMS's user avatar
  • 197
0 votes
1 answer
35 views

I have a data set with postive negative values computing LN in awk using if statement conditions

I have large datasets in where the natural log (LN) is being computed. However, there is many cases where there are negative values and awk is kicking out a warning line for each occurrence and will ...
stormctr2's user avatar
0 votes
1 answer
120 views

Bash math: off-by-one or error calculating if a number is divisible by another number

I used the solution from this answer in a script I'm working on, but it doesn't seem to be working for me. I'm on Bash 5. Here's a simplified test case, I would expect the do_thing function to be ...
Zac Anger's user avatar
  • 233
1 vote
3 answers
667 views

Fitting a equation to a set of data

I have a set of data: 1.12158 0.42563 0.07 1.12471 0.42112 0.07 1.12784 0.41685 0.07 1.13097 0.41283 0.07 1.13409 0.40907 0.07 1.13722 0.40556 0.07 1.14035 0.40231 0.07 1.14348 0.39933 0.07 1.1466 0....
physu's user avatar
  • 201
0 votes
3 answers
77k views

Prime Number Calculation using shell scripting

Last line is not executing when the number is prime. Please help #!/bin/bash echo -e "Enter Number : \c" read n while [ $n -gt 2 ] do for((i=2; i<=$n/2; i++)) do ans=$(( n%i )) if [ $ans -eq 0 ...
Ankit Kumar's user avatar
2 votes
2 answers
773 views

Does shell maths run in a subshell?

When I perform a simple math operation in #!/bin/sh, does that create a subshell? E.g., addition=$(( 1 + 1 )) The syntax would suggest a subshell, but I couldn't find anything on this
Nick Bull's user avatar
  • 563
2 votes
1 answer
213 views

Gnuplot Precission

Does anyone know whether there is a way to run gnuplot with quadruple arithmetic precision? E.g. When you want to plot a line and you want to subtract a value like "2....
Jannis Erhard's user avatar
2 votes
4 answers
2k views

How can I feed a string to awk for the purpose of mathematical calculation?

#!/bin/sh -- expression_to_evaluate='12 + 3' printf '%s\n' "Arithemtic Expansion: $(( $expression_to_evaluate ))" printf '%s' 'bc: ' printf '%s\n' "$expression_to_evaluate" | bc printf '%s' 'awk: '...
Harold Fischer's user avatar
-3 votes
2 answers
239 views

What do comm and diff try to accomplish at input/output level?

Given two files, for each line in each file, how do comm and diff determine whether the line also occur in the other file? if it does, whether its occurrences in the two files are the same or ...
Tim's user avatar
  • 103k
1 vote
5 answers
2k views

$@ used in a loop for math

I am trying to write a Bash script that takes a list of numbers as command line arguments and then outputs the sum of those numbers. So the script would be run as script.sh 1 555 22 122 66 and would ...
DanMan3395's user avatar
2 votes
1 answer
1k views

Error during static build of libvorbis and libmp3lame

I'm having trouble trying to build a static binary of ffmpeg - I've got almost the whole build working, with the exception of two libs - libvorbis and libmp3lame. These two libs are failing during ./...
kralewitz's user avatar
2 votes
1 answer
5k views

How to do math manipulation with variables in conky?

This is part of my conky code. conky.config = { alignment = 'top_right', background = true, color2 = '2ECC71', cpu_avg_samples = 2, default_color = 'FFFFFF', double_buffer = ...
Ébe Isaac's user avatar
0 votes
1 answer
2k views

How to script an an exponential function that decrements the value of the exponent every iteration so that the exponent does not grow?

New to Linux and having problems getting this script to run. Been working on something to take large numbers and use the remainder (modulus) to store the result ( to save memory ). Using the bash ...
Post Apocalyptic's user avatar
0 votes
1 answer
669 views

Using seq and math to manipulate the last octet in an ip address to create a file

Ubuntu 16.04 GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu) We have to add ips to servers a few times a day. I find myself creating different variations of the same file according to the ...
Vituvo's user avatar
  • 411
-1 votes
1 answer
258 views

Como calcular um número fatorial em Bash puro - (Ex.: 5!) [closed]

Trying to translate: What is a basic, elegant and fast way, to write factorial in Bash/in a shell script, purely. (Code) Please make suggestions. (Code) Tem outra alternativa mais básica/...
Helio Giroto's user avatar
0 votes
1 answer
52 views

Using gawk to alter columns after a line identifier

I have multiple drawing files in the format detailed below. I need to increase the value of a number in the area of the file below after the line BO. All values (in the sample below) that are 14.00 ...
2CV375's user avatar
  • 3
0 votes
2 answers
2k views

Hexadecimals to decimal $((0039))

I have a long file with values like this: 0030..0039 2194..2199 21A9..21AA 231A..231B 23E9..23F3 23F8..23FA 25AA..25AB I want to convert the hexadecimals to decimal format. I'm reading that you can ...
Philip Kirkbride's user avatar
1 vote
4 answers
2k views

Increment decimal values to next integer value

I want to increment the decimal value to next integer value through shell script. For example: i=**1.6** then I need to print i=**2** i=**1.00001** then I need to print i=**2** i=**1.00049** ...
Sandosh Kumar P's user avatar
1 vote
1 answer
1k views

Checking that a decimal number is in a range in bc

I've written this if, that is obviously not working, and I still can't manage to get over it: #LASTEFFECTIVEHASH if (( $(echo "$LASTEFFECTIVEHASHMINVAL < $LASTEFFECTIVEHASH < $...
Marco's user avatar
  • 438
2 votes
1 answer
492 views

primality test binary

I'm generating numbers using a Java program (BigIntegers) and I want to know if there's a binary readily available that I could use to run primality tests on the numbers generated.... suppose I feed ...
eftshift0's user avatar
  • 605
2 votes
1 answer
274 views

How to grep a pdf for math?

Is there any way to grep a pdf document (originally written in LaTeX) for the math "2^n" as in 2 to the power of n? I have pdfgrep but I don't know how you would use that to grep for math.
Simd's user avatar
  • 367
0 votes
2 answers
80 views

BASH script to catch changes to a file greater than 150MB

Need some ideas here. I was using something along the lines of if $[$x-$y>1500] then etc.... to detect the size of the changes to a file. I've realized that won't work as the files sizes could ...
morgro269's user avatar
1 vote
1 answer
1k views

Calculate LPAR CPU utilization (AIX)

I'm trying to calculate the CPU utilization of an LPAR but I get wrong results. I can see the utilization in the HMC Web Interface, but Id like to calculate it myself for own purposes. My test: I take ...
Michael's user avatar
  • 113
13 votes
1 answer
1k views

How does printf round halves to the first decimal place?

I am testing two different implementations of printf on my system: printf (GNU coreutils) 8.26, and the version bundled with zsh 5.3.1. I am testing how half numbers are rounded, i.e. for 1.5, 2.5, 3....
Sparhawk's user avatar
  • 20.1k
3 votes
1 answer
410 views

Start bc with pi defined

I would like to create an alias for bc that runs bc -l and specifies that pi=4*a(1). This way, I can start each session with pi already defined. What alias will do this?
gmarmstrong's user avatar
  • 1,233
0 votes
1 answer
3k views

What is the difference between bcl and expr?

I know that both of them can do simple arithmetic. I'm wondering when it will be easier to use one versus the other. I know that expr evaluates an expression from its arguments, while bcl evaluates ...
Hurricane Hamilton's user avatar
-1 votes
2 answers
216 views

Trying to complete Project Euler #5, passes all syntax checks but doesn't work

trying to complete Project Euler #5. The code I have should logically work, and it passes ShellCheck, but gives no output for some reason. The code is below. Thanks and sorry if this should be in a ...
Egrodo's user avatar
  • 207
1 vote
0 answers
128 views

To divide a a loop variable per se and save in another one to be used later

I am facing a problem with bash script: I have a set of variables 'i' that ranges from 3.31 up to 3.35. My script prints out, as a function of the variable 'i' some input file for geometrical ...
Tommy's user avatar
  • 11
9 votes
1 answer
4k views

How to install R plotly in Debian?

I am studying data visualisation with Matrices, Eigen matrices and network graphs, and I am trying to visualise 1D ECG signal by network graphs. I feel the current tools ggnet2 and plotly may be ...
Léo Léopold Hertz 준영's user avatar
2 votes
1 answer
135 views

Better Solution for Finding ID Groups (Permutations/Combinations)

My goal for this question is to find a more efficient solution to accomplish a task. I have a file containing rows of IDs, e.g.: 1001 1004 1005 1010 1006 1020 1002 1002 1005 1006 1001 1010 1020 1043 ...
MSF004's user avatar
  • 305
-2 votes
3 answers
132 views

How can I compute the sum of all i² for i between n and m?

How can I write a script to sum the squares of integers between two values n and m, meaning the sum of all i², where i runs from n to m?
MKHorse's user avatar
  • 11