banner



How To Make Mathematica Give A Fraction Answer

Adding 1/2+1/3 gives an exact answer as a fraction:

In[1]:=

Click for copyable input

Out[1]=

Get an approximate numerical answer:

In[2]:=

Click for copyable input

Out[2]=

If there's any decimal number in your input, the Wolfram Language will automatically give you an approximate answer.

The presence of a decimal number makes the result be approximate:

In[3]:=

Click for copyable input

Out[3]=

In[4]:=

Click for copyable input

Out[4]=

Here's 2 raised to the power 1000:

In[5]:=

Click for copyable input

Out[5]=

Get a numerical approximation:

In[6]:=

Click for copyable input

Out[6]=

Enter a number in scientific notation:

In[7]:=

Click for copyable input

Out[7]=

Get a numerical approximation to π:

In[8]:=

Click for copyable input

Out[8]=

Compute 250 digits of π:

In[9]:=

Click for copyable input

Out[9]=

Generate a random real number in the range 0 to 10:

In[10]:=

Click for copyable input

Out[10]=

Generate 5 random real numbers:

In[11]:=

Click for copyable input

Out[11]=

An alternative way to ask for 5 random real numbers:

In[12]:=

Click for copyable input

Out[12]=

In[13]:=

Click for copyable input

Out[13]=

The Wolfram Language has a huge range of mathematical functions built in, from basic to very sophisticated.

In[14]:=

Click for copyable input

Out[14]=

Find the millionth prime number:

In[15]:=

Click for copyable input

Out[15]=

Plot the first 50 primes:

In[16]:=

Click for copyable input

Out[16]=

The square root of 16 is 4:

In[17]:=

Click for copyable input

Out[17]=

If you don't ask for a numerical approximation, you'll get an exact formula:

In[18]:=

Click for copyable input

Out[18]=

N gives a numerical approximation:

In[19]:=

Click for copyable input

Out[19]=

Make an ordinary ListPlot of the masses of the planets:

In[20]:=

Click for copyable input

Out[20]=

In[21]:=

Click for copyable input

Out[21]=

Abs effectively just drops minus signs:

In[22]:=

Click for copyable input

Out[22]=

Next there's Round, which rounds to the nearest whole number.

Round rounds to the nearest whole number:

In[23]:=

Click for copyable input

Out[23]=

Another function that's very useful is Mod. Let's say you're counting up minutes in an hour. When you reach 60, you'll want to start again from 0. That's what Mod lets you do.

Compute a sequence of numbers mod 60:

In[24]:=

Click for copyable input

Out[24]=

N[expr] numerical approximation
Pi the number π (pi)3.14
Sqrt[x] square root
Log10[x] logarithm to base 10
Log[x] natural logarithm (ln)
Abs[x] absolute value (drop minus signs)
Round[x] round to nearest integer
Prime[n] n th prime number
Mod[x,n] modulo ("clock arithmetic")
RandomReal[max] random real number between 0 and max
RandomReal[max,n] list of n random real numbers
ListLogPlot[data] plot on a logarithmic scale

23.1Find to 500-digit precision. »

Expected output:

Out[]=

23.2Generate 10 random real numbers between 0 and 1. »

Sample expected output:

Out[]=

23.3Make a plot of 200 points with random real x and y coordinates between 0 and 1. »

Sample expected output:

Out[]=

23.4Create a random walk using AnglePath and 1000 random real numbers between 0 and 2π. »

Sample expected output:

Out[]=

23.5Make a table of Mod[n^2, 10] for n from 0 to 30. »

Expected output:

Out[]=

23.6Make a line plot of Mod[n^n, 10] for n from 1 to 100. »

Expected output:

Out[]=

23.7Make a table of the first 10 powers of π, rounded to integers. »

Expected output:

Out[]=

23.8Make a graph by connecting n with Mod[n^2, 100] for n from 0 to 99. »

Expected output:

Out[]=

Sample expected output:

Out[]=

Expected output:

Out[]=

23.11Make a line plot of the differences between successive primes up to 100. »

Expected output:

Out[]=

23.12Generate a sequence of 20 middle C notes with random durations between 0 and 0.5 seconds. »

Sample expected output:

Out[]=

23.13Make an array plot of Mod[i, j] for i and j up to 50. »

Expected output:

Out[]=

23.14Make a list for n from 2 to 10 of array plots for x and y up to 50 of x^y mod n. »

Expected output:

Out[]=

+23.1Use Round to compute the fractional part of π to 50 digits. »

Expected output:

Out[]=

+23.2Find the sum of the first 1000 prime numbers. »

Expected output:

Out[]=

+23.3Make a list of the first 100 primes modulo 4. »

Expected output:

Out[]=

+23.4Make a list of the first 10000 primes modulo 4, multiply them by 90° and create an angle path from them. »

Expected output:

Out[]=

From standard school math, ones like Sin, Cos, ArcTan, Exp, as well as GCD, Factorial, Fibonacci. From physics and engineering and higher math, ones like Gamma ("gamma function"), BesselJ ("Bessel function"), EllipticK ("elliptic integral"), Zeta ("Riemann zeta function"), PrimePi, EulerPhi. From statistics, ones like Erf, NormalDistribution, ChiSquareDistribution. Hundreds of functions altogether.

What does the at the end of each line in a long number mean?

It's there to show that the number continues onto the next linelike a hyphen in text.

Why does N[1.5/7, 100] not give me a 100-digit result?

Because 1.5 is an approximate number with much less than 100-digit precision. N[15/70, 100] will for example give a 100-digit-precision number.

  • The Wolfram Language does "arbitrary-precision computation", meaning that it can keep as many digits in a number as you want.
  • When you generate a number with a certain precision using N, the Wolfram Language will automatically keep track of how that precision is affected by computationsso you don't have to do your own numerical analysis of roundoff errors.
  • If you type a number like 1.5, it's assumed to be at the native "machine precision" of numbers on your computer (usually about 16 digits, though only 6 are usually displayed). Use 1.5 `100 to specify 100-digit precision.
  • With exact input (like 4 or 2/3 or Pi), the Wolfram Language always tries to give exact output. But if the input contains an approximate number (like 2.3), or if you use N, it'll use numerical approximation.
  • Numerical approximation is often crucial in making large-scale computations feasible.
  • PrimeQ tests if a number is prime (see Section 28). FactorInteger finds the factors of an integer.
  • RandomReal can give numbers that aren't just uniformly distributed. For example, RandomReal[NormalDistribution[ ]] gives normally distributed numbers.
  • Round rounds to the nearest integer (up or down); Floor always rounds down; Ceiling always rounds up.
  • RealDigits is the analog of IntegerDigits for real numbers.

How To Make Mathematica Give A Fraction Answer

Source: https://www.wolfram.com/language/elementary-introduction/2nd-ed/23-more-about-numbers.html

Posted by: smithknorted.blogspot.com

0 Response to "How To Make Mathematica Give A Fraction Answer"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel