How can I show radius of this circle exactly?Issue with Expansions of Nested MacrosHow do I split large numbers into groups of five digits?How can I automatically calculate sums in a LaTeX table?How can I nest coordinate calculations in TikZ?How to translate this scenario to LaTeX looping macro?How can I show base-2 long division?How can I convert units in LaTeX environment?How can I multiply two numbers?How can I illustrate point decimal number to binary conversionHow can I calculate geometric sequence in LaTeX?

Is the Amazon rainforest the "world's lungs"?

Notice period 60 days but I need to join in 45 days

What should be done with the carbon when using magic to get oxygen from carbon dioxide?

Within what limits can the prime minister ask the queen to prorogue parliament?

Spicing up a moment of peace

Employing a contractor proving difficult

Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?

Why didn't Doc believe Marty was from the future?

How did medieval manors handle population growth? Were there room for more fields to be ploughed?

Is this password scheme legit?

Should I use the words "pyromancy" and "necromancy" even if they don't mean what people think they do?

Are spot colors limited and why CMYK mix is not treated same as spot color mix?

Why can't you say don't instead of won't?

Cutting numbers into a specific decimals

Are sweatpants frowned upon on flights?

Why is there no Disney logo in MCU movies?

Fantasy Macro Economics: What would Merfolk trade for?

Is the internet in Madagascar faster than in UK?

Term used to describe a person who predicts future outcomes

How could a self contained organic body propel itself in space

Can someone identify this unusual plane at airport?

What to do about my 1-month-old boy peeing through diapers?

Did ancient peoples ever hide their treasure behind puzzles?

Why nature prefers simultaneous events?



How can I show radius of this circle exactly?


Issue with Expansions of Nested MacrosHow do I split large numbers into groups of five digits?How can I automatically calculate sums in a LaTeX table?How can I nest coordinate calculations in TikZ?How to translate this scenario to LaTeX looping macro?How can I show base-2 long division?How can I convert units in LaTeX environment?How can I multiply two numbers?How can I illustrate point decimal number to binary conversionHow can I calculate geometric sequence in LaTeX?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








7















I want to show radius of this circle. The correct result of radius is 7/sqrt(3). My code.



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
pgfmathparsemyr
pgfmathresult
endtikzpicture
enddocument


I tried



pgfmathparsemyr
pgfmathresult


I can't obtain the result. How can I get the result automatically (not by hand)?










share|improve this question


























  • E.g. draw (T) -- (C) node[midway,sloped,fill=white] $pgfmathprintnumbermyr$cm;.

    – Schrödinger's cat
    Aug 16 at 5:03











  • @Dunno This is an approximate result. Can I get exactly result?

    – minhthien_2016
    Aug 16 at 5:07











  • pgfmathparsemyr xdefrpgfmathresult $r cm$

    – koleygr
    Aug 16 at 5:23












  • @koleygr The approximate about 4.0414518843273803516. I want to exactly result.

    – minhthien_2016
    Aug 16 at 5:27






  • 1





    @koleygr Yes. frac73cdotsqrt3.

    – minhthien_2016
    Aug 16 at 5:31

















7















I want to show radius of this circle. The correct result of radius is 7/sqrt(3). My code.



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
pgfmathparsemyr
pgfmathresult
endtikzpicture
enddocument


I tried



pgfmathparsemyr
pgfmathresult


I can't obtain the result. How can I get the result automatically (not by hand)?










share|improve this question


























  • E.g. draw (T) -- (C) node[midway,sloped,fill=white] $pgfmathprintnumbermyr$cm;.

    – Schrödinger's cat
    Aug 16 at 5:03











  • @Dunno This is an approximate result. Can I get exactly result?

    – minhthien_2016
    Aug 16 at 5:07











  • pgfmathparsemyr xdefrpgfmathresult $r cm$

    – koleygr
    Aug 16 at 5:23












  • @koleygr The approximate about 4.0414518843273803516. I want to exactly result.

    – minhthien_2016
    Aug 16 at 5:27






  • 1





    @koleygr Yes. frac73cdotsqrt3.

    – minhthien_2016
    Aug 16 at 5:31













7












7








7








I want to show radius of this circle. The correct result of radius is 7/sqrt(3). My code.



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
pgfmathparsemyr
pgfmathresult
endtikzpicture
enddocument


I tried



pgfmathparsemyr
pgfmathresult


I can't obtain the result. How can I get the result automatically (not by hand)?










share|improve this question
















I want to show radius of this circle. The correct result of radius is 7/sqrt(3). My code.



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
pgfmathparsemyr
pgfmathresult
endtikzpicture
enddocument


I tried



pgfmathparsemyr
pgfmathresult


I can't obtain the result. How can I get the result automatically (not by hand)?







calculations






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 16 at 5:13







minhthien_2016

















asked Aug 16 at 4:34









minhthien_2016minhthien_2016

2,2531 gold badge12 silver badges19 bronze badges




2,2531 gold badge12 silver badges19 bronze badges















  • E.g. draw (T) -- (C) node[midway,sloped,fill=white] $pgfmathprintnumbermyr$cm;.

    – Schrödinger's cat
    Aug 16 at 5:03











  • @Dunno This is an approximate result. Can I get exactly result?

    – minhthien_2016
    Aug 16 at 5:07











  • pgfmathparsemyr xdefrpgfmathresult $r cm$

    – koleygr
    Aug 16 at 5:23












  • @koleygr The approximate about 4.0414518843273803516. I want to exactly result.

    – minhthien_2016
    Aug 16 at 5:27






  • 1





    @koleygr Yes. frac73cdotsqrt3.

    – minhthien_2016
    Aug 16 at 5:31

















  • E.g. draw (T) -- (C) node[midway,sloped,fill=white] $pgfmathprintnumbermyr$cm;.

    – Schrödinger's cat
    Aug 16 at 5:03











  • @Dunno This is an approximate result. Can I get exactly result?

    – minhthien_2016
    Aug 16 at 5:07











  • pgfmathparsemyr xdefrpgfmathresult $r cm$

    – koleygr
    Aug 16 at 5:23












  • @koleygr The approximate about 4.0414518843273803516. I want to exactly result.

    – minhthien_2016
    Aug 16 at 5:27






  • 1





    @koleygr Yes. frac73cdotsqrt3.

    – minhthien_2016
    Aug 16 at 5:31
















E.g. draw (T) -- (C) node[midway,sloped,fill=white] $pgfmathprintnumbermyr$cm;.

– Schrödinger's cat
Aug 16 at 5:03





E.g. draw (T) -- (C) node[midway,sloped,fill=white] $pgfmathprintnumbermyr$cm;.

– Schrödinger's cat
Aug 16 at 5:03













@Dunno This is an approximate result. Can I get exactly result?

– minhthien_2016
Aug 16 at 5:07





@Dunno This is an approximate result. Can I get exactly result?

– minhthien_2016
Aug 16 at 5:07













pgfmathparsemyr xdefrpgfmathresult $r cm$

– koleygr
Aug 16 at 5:23






pgfmathparsemyr xdefrpgfmathresult $r cm$

– koleygr
Aug 16 at 5:23














@koleygr The approximate about 4.0414518843273803516. I want to exactly result.

– minhthien_2016
Aug 16 at 5:27





@koleygr The approximate about 4.0414518843273803516. I want to exactly result.

– minhthien_2016
Aug 16 at 5:27




1




1





@koleygr Yes. frac73cdotsqrt3.

– minhthien_2016
Aug 16 at 5:31





@koleygr Yes. frac73cdotsqrt3.

– minhthien_2016
Aug 16 at 5:31










1 Answer
1






active

oldest

votes


















8















There is only very limited support for fraction detection and so on in pgf, and as soon as square roots are involved I think you do need to do some of the things by hand. (To be fair, computer algebra systems are also not great at detecting such expressions, but if you use those to parse the expressions then you can get exact result. Yet LaTeX is not such a computer algebra system.) You can use the keys



pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false


to obtain



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
pgfmathparsemyr/sqrt(3)%
pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false%
$pgfmathprintnumberpgfmathresultcdotsqrt3,$cm;
endtikzpicture
enddocument


enter image description here



Of course, one can do better than that but to the best of my knowledge the routines for doing the required integer arithmetic are not yet implemented in pgf (and there is a slight chance that there is no real package for those). The main obstacle is that gcd, which is very useful to cancel common factors in fractions, does not yet work with fpu. On the other hand, you need fpu here because the numbers are so large. So I added variant of gcd (called gcdFPU) and a number of other routines such as integerpower which allows one to determine the power of a factor in an integer. For instance, integerpower(12,2) yields 2 since 12=2^2 times something that is not divisible by 2. This can be used to pull squares out of the square root.



documentclass[tikz,border=1mm]standalone 
usepackagetikz-3dplot
usetikzlibraryfpu
newcounterifactor
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
newcommandPgfmathtruncatemacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathtruncatemacro#1round(#2)%
pgfmathsmuggle#1endgroup
% the following functions are based on
% * https://tex.stackexchange.com/a/177109 (digitcount,digitsum,lastdigit)
% * https://tex.stackexchange.com/a/501895 (memberQ)
% or new in the sense that they were developed on the basis of the existing
% pgf functions
makeatletter
newcountc@Digits
newcountc@Powers
pgfmathdeclarefunctiondigitcount1%
begingroup%
globalc@Digits=0
expandafterDigitCount@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defGroupDigits#1%
% globalc@Digits=0
% expandafterDigitCount@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitCount@i#1#2@nil%
advancec@Digits by @ne
ifxrelax#2relaxelseDigitCount@i#2@nilfi

pgfmathdeclarefunctiondigitsum1%
begingroup%
globalc@Digits=0
expandafterDigitSum@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defDigitSum#1%
% globalc@Digits=0
% expandafterDigitSum@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitSum@i#1#2@nil%
advancec@Digits by #1
ifxrelax#2relaxelseDigitSum@i#2@nilfi

pgfmathdeclarefunctionlastdigit1%
begingroup%
globalc@Digits=0
expandafterLastDigit@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defLastDigit#1%
% globalc@Digits=0
% expandafterLastDigit@i#1@nil%
% pgfmathparseint(thec@Digits)
defLastDigit@i#1#2@nil%
c@Digits=#1
ifxrelax#2relaxelseLastDigit@i#2@nilfi

pgfmathdeclarefunctionintegerpower2%
begingroup%
globalc@Powers=0%
pgfmathtruncatemacropgfutil@tmpa#1%
looppgfmathtruncatemacroitestgcd(pgfutil@tmpa,#2)%0
ifnumitest>1relax%
advancec@Powers by @ne%
pgfmathtruncatemacropgfutil@tmpapgfutil@tmpa/#2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower21% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacropgfutil@tmpblastdigit(pgfutil@tmpa)%
pgfmathtruncatemacroitestiseven(pgfutil@tmpb)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower31% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacroitestdivby3(pgfutil@tmpa)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/3%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionmemberQ2%
begingroup%
edefpgfutil@tmpb0%
edefpgfutil@tmpa#2%
expandafterpgfmath@member@ipgfutil@firstofone#1pgfmath@token@stop
edefpgfmathresultpgfutil@tmpb%
pgfmath@smuggleonepgfmathresult%
endgroup
defpgfmath@member@i#1%
ifxpgfmath@token@stop#1%
else
ifnum#1=pgfutil@tmparelax%
gdefpgfutil@tmpb1%
fi%
expandafterpgfmath@member@i
fi
pgfmathdeclarefunctionisevenFPU1%
begingroup%
pgfmathparseiseven(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionisoddFPU1%
begingroup%
pgfmathparseisodd(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiondivby31%
begingroup%
pgfmathparsememberQ(3,6,9,digitsum(digitsum(#1)))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiongcdFPU2%
begingroup
pgfkeys/pgf/fpu=false%
pgfmathcontinuelooptrue
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
PgfmathtruncatemacroFPUpgfutil@tmpb#2%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpb%
fi%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpb==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpa%
fi%
PgfmathtruncatemacroFPUpgfutil@tmpaabs(pgfutil@tmpa)%
PgfmathtruncatemacroFPUpgfutil@tmpbabs(pgfutil@tmpb)%
loop
ifpgfmathcontinueloop%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==pgfutil@tmpb,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
else
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa>pgfutil@tmpb,1,0)%
ifnumitest=1relax
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa-pgfutil@tmpb%
else
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpb-pgfutil@tmpa%
fi
fi
repeat
PgfmathtruncatemacroFPUpgfmathresultpgfutil@tmpa%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionfactorinteger1%
begingroup% not yet done
endgroup

makeatother

newcommandPgfmathfraction[3]begingroup%
pgfmathtruncatemacromynumerator#2/gcd(#2,#3)%
pgfmathtruncatemacromydenominator#3/gcd(#2,#3)%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
foreach a/b/c in 3/4/5,6/7/8,5/7/8
begintikzpicture[tdplot_main_coords,line join = round, line cap = round,
declare function=numerator(a,b,c)=pow(a,2) *pow(b,2)* pow(c,2);
denominator(a,b,c)=-pow(a,4) - pow(b,4) - pow(c,4)+%
2*pow(a,2) *pow(b,2)+2*pow(c,2) *pow(b,2)+2*pow(c,2)*pow(a,2);]
beginscope[local bounding box=elli]
PgfmathtruncatemacroFPUmynumeratornumerator(a,b,c)
PgfmathtruncatemacroFPUmydenominatordenominator(a,b,c)
PgfmathtruncatemacroFPUmygcdgcdFPU(mynumerator,mydenominator)
messagenumerator=mynumerator,denominator=mydenominator,gcd=mygcd^^J
PgfmathtruncatemacroFPUnewnumeratormynumerator/mygcd
PgfmathtruncatemacroFPUnewdenominatormydenominator/mygcd
messagenew numerator=newnumerator,new denominator=newdenominator^^J
pgfmathtruncatemacromyprenum1
pgfmathtruncatemacromypreden1
foreach Prime in 2,3,5,7,11,13,17
pgfmathtruncatemacromyintintegerpower(newnumerator,Prime)
ifnummyint>1
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewnumeratornewnumerator/pow(Prime,myint)
xdefnewnumeratornewnumerator
pgfmathtruncatemacromyprenummyprenum*pow(Prime,myint/2)
xdefmyprenummyprenum
fi
pgfmathtruncatemacromyintintegerpower(newdenominator,Prime)
ifnummyint>0
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewdenominatornewdenominator/pow(Prime,myint)
xdefnewdenominatornewdenominator
pgfmathtruncatemacromypredenmypreden*pow(Prime,myint/2)
xdefmypredenmypreden
fi

messagenew numerator=newnumerator, pre num=myprenum,new
denominator=newdenominator, pre den=mypreden^^J
pgfmathsetmacromyr(myprenum/mypreden)*sqrt(newnumerator/newdenominator)
coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
$displaystyleifnummypreden=1
myprenum
else
fracmyprenummypreden
fi
ifnumnewdenominator=1
ifnumnewnumerator=1
else
cdotsqrtnewnumerator
fi
else
ifnumnewnumerator=1
cdotfrac1sqrtnewdenominator
else
cdotsqrtfracnewnumeratornewdenominator
fi
fi,$cm;
endscope
node[above] at (elli.north)$a=a,b=b,c=c$;
endtikzpicture
enddocument


enter image description here






share|improve this answer



























  • I think, your answer is not automatically.

    – minhthien_2016
    Aug 16 at 5:58











  • Dunmo. I voted for your answer. But, your code doesn't true in every cases. E.G, triangle with lenght 6, 7, 8.

    – minhthien_2016
    Aug 16 at 10:34











  • Please try with sides 3, 4, 5. It is incorrect.

    – minhthien_2016
    Aug 16 at 10:36












  • Thank you very much.

    – minhthien_2016
    Aug 16 at 23:05






  • 1





    You can see package xintexpr.

    – minhthien_2016
    Aug 17 at 4:25













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f504392%2fhow-can-i-show-radius-of-this-circle-exactly%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









8















There is only very limited support for fraction detection and so on in pgf, and as soon as square roots are involved I think you do need to do some of the things by hand. (To be fair, computer algebra systems are also not great at detecting such expressions, but if you use those to parse the expressions then you can get exact result. Yet LaTeX is not such a computer algebra system.) You can use the keys



pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false


to obtain



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
pgfmathparsemyr/sqrt(3)%
pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false%
$pgfmathprintnumberpgfmathresultcdotsqrt3,$cm;
endtikzpicture
enddocument


enter image description here



Of course, one can do better than that but to the best of my knowledge the routines for doing the required integer arithmetic are not yet implemented in pgf (and there is a slight chance that there is no real package for those). The main obstacle is that gcd, which is very useful to cancel common factors in fractions, does not yet work with fpu. On the other hand, you need fpu here because the numbers are so large. So I added variant of gcd (called gcdFPU) and a number of other routines such as integerpower which allows one to determine the power of a factor in an integer. For instance, integerpower(12,2) yields 2 since 12=2^2 times something that is not divisible by 2. This can be used to pull squares out of the square root.



documentclass[tikz,border=1mm]standalone 
usepackagetikz-3dplot
usetikzlibraryfpu
newcounterifactor
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
newcommandPgfmathtruncatemacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathtruncatemacro#1round(#2)%
pgfmathsmuggle#1endgroup
% the following functions are based on
% * https://tex.stackexchange.com/a/177109 (digitcount,digitsum,lastdigit)
% * https://tex.stackexchange.com/a/501895 (memberQ)
% or new in the sense that they were developed on the basis of the existing
% pgf functions
makeatletter
newcountc@Digits
newcountc@Powers
pgfmathdeclarefunctiondigitcount1%
begingroup%
globalc@Digits=0
expandafterDigitCount@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defGroupDigits#1%
% globalc@Digits=0
% expandafterDigitCount@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitCount@i#1#2@nil%
advancec@Digits by @ne
ifxrelax#2relaxelseDigitCount@i#2@nilfi

pgfmathdeclarefunctiondigitsum1%
begingroup%
globalc@Digits=0
expandafterDigitSum@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defDigitSum#1%
% globalc@Digits=0
% expandafterDigitSum@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitSum@i#1#2@nil%
advancec@Digits by #1
ifxrelax#2relaxelseDigitSum@i#2@nilfi

pgfmathdeclarefunctionlastdigit1%
begingroup%
globalc@Digits=0
expandafterLastDigit@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defLastDigit#1%
% globalc@Digits=0
% expandafterLastDigit@i#1@nil%
% pgfmathparseint(thec@Digits)
defLastDigit@i#1#2@nil%
c@Digits=#1
ifxrelax#2relaxelseLastDigit@i#2@nilfi

pgfmathdeclarefunctionintegerpower2%
begingroup%
globalc@Powers=0%
pgfmathtruncatemacropgfutil@tmpa#1%
looppgfmathtruncatemacroitestgcd(pgfutil@tmpa,#2)%0
ifnumitest>1relax%
advancec@Powers by @ne%
pgfmathtruncatemacropgfutil@tmpapgfutil@tmpa/#2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower21% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacropgfutil@tmpblastdigit(pgfutil@tmpa)%
pgfmathtruncatemacroitestiseven(pgfutil@tmpb)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower31% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacroitestdivby3(pgfutil@tmpa)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/3%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionmemberQ2%
begingroup%
edefpgfutil@tmpb0%
edefpgfutil@tmpa#2%
expandafterpgfmath@member@ipgfutil@firstofone#1pgfmath@token@stop
edefpgfmathresultpgfutil@tmpb%
pgfmath@smuggleonepgfmathresult%
endgroup
defpgfmath@member@i#1%
ifxpgfmath@token@stop#1%
else
ifnum#1=pgfutil@tmparelax%
gdefpgfutil@tmpb1%
fi%
expandafterpgfmath@member@i
fi
pgfmathdeclarefunctionisevenFPU1%
begingroup%
pgfmathparseiseven(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionisoddFPU1%
begingroup%
pgfmathparseisodd(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiondivby31%
begingroup%
pgfmathparsememberQ(3,6,9,digitsum(digitsum(#1)))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiongcdFPU2%
begingroup
pgfkeys/pgf/fpu=false%
pgfmathcontinuelooptrue
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
PgfmathtruncatemacroFPUpgfutil@tmpb#2%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpb%
fi%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpb==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpa%
fi%
PgfmathtruncatemacroFPUpgfutil@tmpaabs(pgfutil@tmpa)%
PgfmathtruncatemacroFPUpgfutil@tmpbabs(pgfutil@tmpb)%
loop
ifpgfmathcontinueloop%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==pgfutil@tmpb,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
else
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa>pgfutil@tmpb,1,0)%
ifnumitest=1relax
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa-pgfutil@tmpb%
else
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpb-pgfutil@tmpa%
fi
fi
repeat
PgfmathtruncatemacroFPUpgfmathresultpgfutil@tmpa%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionfactorinteger1%
begingroup% not yet done
endgroup

makeatother

newcommandPgfmathfraction[3]begingroup%
pgfmathtruncatemacromynumerator#2/gcd(#2,#3)%
pgfmathtruncatemacromydenominator#3/gcd(#2,#3)%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
foreach a/b/c in 3/4/5,6/7/8,5/7/8
begintikzpicture[tdplot_main_coords,line join = round, line cap = round,
declare function=numerator(a,b,c)=pow(a,2) *pow(b,2)* pow(c,2);
denominator(a,b,c)=-pow(a,4) - pow(b,4) - pow(c,4)+%
2*pow(a,2) *pow(b,2)+2*pow(c,2) *pow(b,2)+2*pow(c,2)*pow(a,2);]
beginscope[local bounding box=elli]
PgfmathtruncatemacroFPUmynumeratornumerator(a,b,c)
PgfmathtruncatemacroFPUmydenominatordenominator(a,b,c)
PgfmathtruncatemacroFPUmygcdgcdFPU(mynumerator,mydenominator)
messagenumerator=mynumerator,denominator=mydenominator,gcd=mygcd^^J
PgfmathtruncatemacroFPUnewnumeratormynumerator/mygcd
PgfmathtruncatemacroFPUnewdenominatormydenominator/mygcd
messagenew numerator=newnumerator,new denominator=newdenominator^^J
pgfmathtruncatemacromyprenum1
pgfmathtruncatemacromypreden1
foreach Prime in 2,3,5,7,11,13,17
pgfmathtruncatemacromyintintegerpower(newnumerator,Prime)
ifnummyint>1
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewnumeratornewnumerator/pow(Prime,myint)
xdefnewnumeratornewnumerator
pgfmathtruncatemacromyprenummyprenum*pow(Prime,myint/2)
xdefmyprenummyprenum
fi
pgfmathtruncatemacromyintintegerpower(newdenominator,Prime)
ifnummyint>0
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewdenominatornewdenominator/pow(Prime,myint)
xdefnewdenominatornewdenominator
pgfmathtruncatemacromypredenmypreden*pow(Prime,myint/2)
xdefmypredenmypreden
fi

messagenew numerator=newnumerator, pre num=myprenum,new
denominator=newdenominator, pre den=mypreden^^J
pgfmathsetmacromyr(myprenum/mypreden)*sqrt(newnumerator/newdenominator)
coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
$displaystyleifnummypreden=1
myprenum
else
fracmyprenummypreden
fi
ifnumnewdenominator=1
ifnumnewnumerator=1
else
cdotsqrtnewnumerator
fi
else
ifnumnewnumerator=1
cdotfrac1sqrtnewdenominator
else
cdotsqrtfracnewnumeratornewdenominator
fi
fi,$cm;
endscope
node[above] at (elli.north)$a=a,b=b,c=c$;
endtikzpicture
enddocument


enter image description here






share|improve this answer



























  • I think, your answer is not automatically.

    – minhthien_2016
    Aug 16 at 5:58











  • Dunmo. I voted for your answer. But, your code doesn't true in every cases. E.G, triangle with lenght 6, 7, 8.

    – minhthien_2016
    Aug 16 at 10:34











  • Please try with sides 3, 4, 5. It is incorrect.

    – minhthien_2016
    Aug 16 at 10:36












  • Thank you very much.

    – minhthien_2016
    Aug 16 at 23:05






  • 1





    You can see package xintexpr.

    – minhthien_2016
    Aug 17 at 4:25















8















There is only very limited support for fraction detection and so on in pgf, and as soon as square roots are involved I think you do need to do some of the things by hand. (To be fair, computer algebra systems are also not great at detecting such expressions, but if you use those to parse the expressions then you can get exact result. Yet LaTeX is not such a computer algebra system.) You can use the keys



pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false


to obtain



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
pgfmathparsemyr/sqrt(3)%
pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false%
$pgfmathprintnumberpgfmathresultcdotsqrt3,$cm;
endtikzpicture
enddocument


enter image description here



Of course, one can do better than that but to the best of my knowledge the routines for doing the required integer arithmetic are not yet implemented in pgf (and there is a slight chance that there is no real package for those). The main obstacle is that gcd, which is very useful to cancel common factors in fractions, does not yet work with fpu. On the other hand, you need fpu here because the numbers are so large. So I added variant of gcd (called gcdFPU) and a number of other routines such as integerpower which allows one to determine the power of a factor in an integer. For instance, integerpower(12,2) yields 2 since 12=2^2 times something that is not divisible by 2. This can be used to pull squares out of the square root.



documentclass[tikz,border=1mm]standalone 
usepackagetikz-3dplot
usetikzlibraryfpu
newcounterifactor
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
newcommandPgfmathtruncatemacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathtruncatemacro#1round(#2)%
pgfmathsmuggle#1endgroup
% the following functions are based on
% * https://tex.stackexchange.com/a/177109 (digitcount,digitsum,lastdigit)
% * https://tex.stackexchange.com/a/501895 (memberQ)
% or new in the sense that they were developed on the basis of the existing
% pgf functions
makeatletter
newcountc@Digits
newcountc@Powers
pgfmathdeclarefunctiondigitcount1%
begingroup%
globalc@Digits=0
expandafterDigitCount@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defGroupDigits#1%
% globalc@Digits=0
% expandafterDigitCount@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitCount@i#1#2@nil%
advancec@Digits by @ne
ifxrelax#2relaxelseDigitCount@i#2@nilfi

pgfmathdeclarefunctiondigitsum1%
begingroup%
globalc@Digits=0
expandafterDigitSum@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defDigitSum#1%
% globalc@Digits=0
% expandafterDigitSum@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitSum@i#1#2@nil%
advancec@Digits by #1
ifxrelax#2relaxelseDigitSum@i#2@nilfi

pgfmathdeclarefunctionlastdigit1%
begingroup%
globalc@Digits=0
expandafterLastDigit@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defLastDigit#1%
% globalc@Digits=0
% expandafterLastDigit@i#1@nil%
% pgfmathparseint(thec@Digits)
defLastDigit@i#1#2@nil%
c@Digits=#1
ifxrelax#2relaxelseLastDigit@i#2@nilfi

pgfmathdeclarefunctionintegerpower2%
begingroup%
globalc@Powers=0%
pgfmathtruncatemacropgfutil@tmpa#1%
looppgfmathtruncatemacroitestgcd(pgfutil@tmpa,#2)%0
ifnumitest>1relax%
advancec@Powers by @ne%
pgfmathtruncatemacropgfutil@tmpapgfutil@tmpa/#2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower21% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacropgfutil@tmpblastdigit(pgfutil@tmpa)%
pgfmathtruncatemacroitestiseven(pgfutil@tmpb)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower31% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacroitestdivby3(pgfutil@tmpa)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/3%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionmemberQ2%
begingroup%
edefpgfutil@tmpb0%
edefpgfutil@tmpa#2%
expandafterpgfmath@member@ipgfutil@firstofone#1pgfmath@token@stop
edefpgfmathresultpgfutil@tmpb%
pgfmath@smuggleonepgfmathresult%
endgroup
defpgfmath@member@i#1%
ifxpgfmath@token@stop#1%
else
ifnum#1=pgfutil@tmparelax%
gdefpgfutil@tmpb1%
fi%
expandafterpgfmath@member@i
fi
pgfmathdeclarefunctionisevenFPU1%
begingroup%
pgfmathparseiseven(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionisoddFPU1%
begingroup%
pgfmathparseisodd(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiondivby31%
begingroup%
pgfmathparsememberQ(3,6,9,digitsum(digitsum(#1)))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiongcdFPU2%
begingroup
pgfkeys/pgf/fpu=false%
pgfmathcontinuelooptrue
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
PgfmathtruncatemacroFPUpgfutil@tmpb#2%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpb%
fi%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpb==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpa%
fi%
PgfmathtruncatemacroFPUpgfutil@tmpaabs(pgfutil@tmpa)%
PgfmathtruncatemacroFPUpgfutil@tmpbabs(pgfutil@tmpb)%
loop
ifpgfmathcontinueloop%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==pgfutil@tmpb,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
else
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa>pgfutil@tmpb,1,0)%
ifnumitest=1relax
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa-pgfutil@tmpb%
else
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpb-pgfutil@tmpa%
fi
fi
repeat
PgfmathtruncatemacroFPUpgfmathresultpgfutil@tmpa%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionfactorinteger1%
begingroup% not yet done
endgroup

makeatother

newcommandPgfmathfraction[3]begingroup%
pgfmathtruncatemacromynumerator#2/gcd(#2,#3)%
pgfmathtruncatemacromydenominator#3/gcd(#2,#3)%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
foreach a/b/c in 3/4/5,6/7/8,5/7/8
begintikzpicture[tdplot_main_coords,line join = round, line cap = round,
declare function=numerator(a,b,c)=pow(a,2) *pow(b,2)* pow(c,2);
denominator(a,b,c)=-pow(a,4) - pow(b,4) - pow(c,4)+%
2*pow(a,2) *pow(b,2)+2*pow(c,2) *pow(b,2)+2*pow(c,2)*pow(a,2);]
beginscope[local bounding box=elli]
PgfmathtruncatemacroFPUmynumeratornumerator(a,b,c)
PgfmathtruncatemacroFPUmydenominatordenominator(a,b,c)
PgfmathtruncatemacroFPUmygcdgcdFPU(mynumerator,mydenominator)
messagenumerator=mynumerator,denominator=mydenominator,gcd=mygcd^^J
PgfmathtruncatemacroFPUnewnumeratormynumerator/mygcd
PgfmathtruncatemacroFPUnewdenominatormydenominator/mygcd
messagenew numerator=newnumerator,new denominator=newdenominator^^J
pgfmathtruncatemacromyprenum1
pgfmathtruncatemacromypreden1
foreach Prime in 2,3,5,7,11,13,17
pgfmathtruncatemacromyintintegerpower(newnumerator,Prime)
ifnummyint>1
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewnumeratornewnumerator/pow(Prime,myint)
xdefnewnumeratornewnumerator
pgfmathtruncatemacromyprenummyprenum*pow(Prime,myint/2)
xdefmyprenummyprenum
fi
pgfmathtruncatemacromyintintegerpower(newdenominator,Prime)
ifnummyint>0
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewdenominatornewdenominator/pow(Prime,myint)
xdefnewdenominatornewdenominator
pgfmathtruncatemacromypredenmypreden*pow(Prime,myint/2)
xdefmypredenmypreden
fi

messagenew numerator=newnumerator, pre num=myprenum,new
denominator=newdenominator, pre den=mypreden^^J
pgfmathsetmacromyr(myprenum/mypreden)*sqrt(newnumerator/newdenominator)
coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
$displaystyleifnummypreden=1
myprenum
else
fracmyprenummypreden
fi
ifnumnewdenominator=1
ifnumnewnumerator=1
else
cdotsqrtnewnumerator
fi
else
ifnumnewnumerator=1
cdotfrac1sqrtnewdenominator
else
cdotsqrtfracnewnumeratornewdenominator
fi
fi,$cm;
endscope
node[above] at (elli.north)$a=a,b=b,c=c$;
endtikzpicture
enddocument


enter image description here






share|improve this answer



























  • I think, your answer is not automatically.

    – minhthien_2016
    Aug 16 at 5:58











  • Dunmo. I voted for your answer. But, your code doesn't true in every cases. E.G, triangle with lenght 6, 7, 8.

    – minhthien_2016
    Aug 16 at 10:34











  • Please try with sides 3, 4, 5. It is incorrect.

    – minhthien_2016
    Aug 16 at 10:36












  • Thank you very much.

    – minhthien_2016
    Aug 16 at 23:05






  • 1





    You can see package xintexpr.

    – minhthien_2016
    Aug 17 at 4:25













8














8










8









There is only very limited support for fraction detection and so on in pgf, and as soon as square roots are involved I think you do need to do some of the things by hand. (To be fair, computer algebra systems are also not great at detecting such expressions, but if you use those to parse the expressions then you can get exact result. Yet LaTeX is not such a computer algebra system.) You can use the keys



pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false


to obtain



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
pgfmathparsemyr/sqrt(3)%
pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false%
$pgfmathprintnumberpgfmathresultcdotsqrt3,$cm;
endtikzpicture
enddocument


enter image description here



Of course, one can do better than that but to the best of my knowledge the routines for doing the required integer arithmetic are not yet implemented in pgf (and there is a slight chance that there is no real package for those). The main obstacle is that gcd, which is very useful to cancel common factors in fractions, does not yet work with fpu. On the other hand, you need fpu here because the numbers are so large. So I added variant of gcd (called gcdFPU) and a number of other routines such as integerpower which allows one to determine the power of a factor in an integer. For instance, integerpower(12,2) yields 2 since 12=2^2 times something that is not divisible by 2. This can be used to pull squares out of the square root.



documentclass[tikz,border=1mm]standalone 
usepackagetikz-3dplot
usetikzlibraryfpu
newcounterifactor
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
newcommandPgfmathtruncatemacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathtruncatemacro#1round(#2)%
pgfmathsmuggle#1endgroup
% the following functions are based on
% * https://tex.stackexchange.com/a/177109 (digitcount,digitsum,lastdigit)
% * https://tex.stackexchange.com/a/501895 (memberQ)
% or new in the sense that they were developed on the basis of the existing
% pgf functions
makeatletter
newcountc@Digits
newcountc@Powers
pgfmathdeclarefunctiondigitcount1%
begingroup%
globalc@Digits=0
expandafterDigitCount@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defGroupDigits#1%
% globalc@Digits=0
% expandafterDigitCount@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitCount@i#1#2@nil%
advancec@Digits by @ne
ifxrelax#2relaxelseDigitCount@i#2@nilfi

pgfmathdeclarefunctiondigitsum1%
begingroup%
globalc@Digits=0
expandafterDigitSum@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defDigitSum#1%
% globalc@Digits=0
% expandafterDigitSum@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitSum@i#1#2@nil%
advancec@Digits by #1
ifxrelax#2relaxelseDigitSum@i#2@nilfi

pgfmathdeclarefunctionlastdigit1%
begingroup%
globalc@Digits=0
expandafterLastDigit@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defLastDigit#1%
% globalc@Digits=0
% expandafterLastDigit@i#1@nil%
% pgfmathparseint(thec@Digits)
defLastDigit@i#1#2@nil%
c@Digits=#1
ifxrelax#2relaxelseLastDigit@i#2@nilfi

pgfmathdeclarefunctionintegerpower2%
begingroup%
globalc@Powers=0%
pgfmathtruncatemacropgfutil@tmpa#1%
looppgfmathtruncatemacroitestgcd(pgfutil@tmpa,#2)%0
ifnumitest>1relax%
advancec@Powers by @ne%
pgfmathtruncatemacropgfutil@tmpapgfutil@tmpa/#2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower21% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacropgfutil@tmpblastdigit(pgfutil@tmpa)%
pgfmathtruncatemacroitestiseven(pgfutil@tmpb)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower31% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacroitestdivby3(pgfutil@tmpa)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/3%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionmemberQ2%
begingroup%
edefpgfutil@tmpb0%
edefpgfutil@tmpa#2%
expandafterpgfmath@member@ipgfutil@firstofone#1pgfmath@token@stop
edefpgfmathresultpgfutil@tmpb%
pgfmath@smuggleonepgfmathresult%
endgroup
defpgfmath@member@i#1%
ifxpgfmath@token@stop#1%
else
ifnum#1=pgfutil@tmparelax%
gdefpgfutil@tmpb1%
fi%
expandafterpgfmath@member@i
fi
pgfmathdeclarefunctionisevenFPU1%
begingroup%
pgfmathparseiseven(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionisoddFPU1%
begingroup%
pgfmathparseisodd(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiondivby31%
begingroup%
pgfmathparsememberQ(3,6,9,digitsum(digitsum(#1)))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiongcdFPU2%
begingroup
pgfkeys/pgf/fpu=false%
pgfmathcontinuelooptrue
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
PgfmathtruncatemacroFPUpgfutil@tmpb#2%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpb%
fi%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpb==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpa%
fi%
PgfmathtruncatemacroFPUpgfutil@tmpaabs(pgfutil@tmpa)%
PgfmathtruncatemacroFPUpgfutil@tmpbabs(pgfutil@tmpb)%
loop
ifpgfmathcontinueloop%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==pgfutil@tmpb,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
else
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa>pgfutil@tmpb,1,0)%
ifnumitest=1relax
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa-pgfutil@tmpb%
else
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpb-pgfutil@tmpa%
fi
fi
repeat
PgfmathtruncatemacroFPUpgfmathresultpgfutil@tmpa%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionfactorinteger1%
begingroup% not yet done
endgroup

makeatother

newcommandPgfmathfraction[3]begingroup%
pgfmathtruncatemacromynumerator#2/gcd(#2,#3)%
pgfmathtruncatemacromydenominator#3/gcd(#2,#3)%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
foreach a/b/c in 3/4/5,6/7/8,5/7/8
begintikzpicture[tdplot_main_coords,line join = round, line cap = round,
declare function=numerator(a,b,c)=pow(a,2) *pow(b,2)* pow(c,2);
denominator(a,b,c)=-pow(a,4) - pow(b,4) - pow(c,4)+%
2*pow(a,2) *pow(b,2)+2*pow(c,2) *pow(b,2)+2*pow(c,2)*pow(a,2);]
beginscope[local bounding box=elli]
PgfmathtruncatemacroFPUmynumeratornumerator(a,b,c)
PgfmathtruncatemacroFPUmydenominatordenominator(a,b,c)
PgfmathtruncatemacroFPUmygcdgcdFPU(mynumerator,mydenominator)
messagenumerator=mynumerator,denominator=mydenominator,gcd=mygcd^^J
PgfmathtruncatemacroFPUnewnumeratormynumerator/mygcd
PgfmathtruncatemacroFPUnewdenominatormydenominator/mygcd
messagenew numerator=newnumerator,new denominator=newdenominator^^J
pgfmathtruncatemacromyprenum1
pgfmathtruncatemacromypreden1
foreach Prime in 2,3,5,7,11,13,17
pgfmathtruncatemacromyintintegerpower(newnumerator,Prime)
ifnummyint>1
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewnumeratornewnumerator/pow(Prime,myint)
xdefnewnumeratornewnumerator
pgfmathtruncatemacromyprenummyprenum*pow(Prime,myint/2)
xdefmyprenummyprenum
fi
pgfmathtruncatemacromyintintegerpower(newdenominator,Prime)
ifnummyint>0
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewdenominatornewdenominator/pow(Prime,myint)
xdefnewdenominatornewdenominator
pgfmathtruncatemacromypredenmypreden*pow(Prime,myint/2)
xdefmypredenmypreden
fi

messagenew numerator=newnumerator, pre num=myprenum,new
denominator=newdenominator, pre den=mypreden^^J
pgfmathsetmacromyr(myprenum/mypreden)*sqrt(newnumerator/newdenominator)
coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
$displaystyleifnummypreden=1
myprenum
else
fracmyprenummypreden
fi
ifnumnewdenominator=1
ifnumnewnumerator=1
else
cdotsqrtnewnumerator
fi
else
ifnumnewnumerator=1
cdotfrac1sqrtnewdenominator
else
cdotsqrtfracnewnumeratornewdenominator
fi
fi,$cm;
endscope
node[above] at (elli.north)$a=a,b=b,c=c$;
endtikzpicture
enddocument


enter image description here






share|improve this answer















There is only very limited support for fraction detection and so on in pgf, and as soon as square roots are involved I think you do need to do some of the things by hand. (To be fair, computer algebra systems are also not great at detecting such expressions, but if you use those to parse the expressions then you can get exact result. Yet LaTeX is not such a computer algebra system.) You can use the keys



pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false


to obtain



documentclass[border = 1mm]standalone 
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryintersections,calc,backgrounds,fpu
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
begintikzpicture[tdplot_main_coords,line join = round, line cap = round]
pgfmathsetmacroa5
pgfmathsetmacrob7
pgfmathsetmacroc8
PgfmathsetmacroFPUmyrsqrt(-
pow(a,2) *pow(b,2)* pow(c,2)/ (pow(a,4) + pow(b,4) + pow(c,4)- 2
*pow(a,2) *pow(b,2) - 2*pow(c,2) *pow(b,2)-2*pow(c,2) *pow(a,2) ))

coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
pgfmathparsemyr/sqrt(3)%
pgfkeys/pgf/number format/.cd,frac, frac denom=3,frac whole=false%
$pgfmathprintnumberpgfmathresultcdotsqrt3,$cm;
endtikzpicture
enddocument


enter image description here



Of course, one can do better than that but to the best of my knowledge the routines for doing the required integer arithmetic are not yet implemented in pgf (and there is a slight chance that there is no real package for those). The main obstacle is that gcd, which is very useful to cancel common factors in fractions, does not yet work with fpu. On the other hand, you need fpu here because the numbers are so large. So I added variant of gcd (called gcdFPU) and a number of other routines such as integerpower which allows one to determine the power of a factor in an integer. For instance, integerpower(12,2) yields 2 since 12=2^2 times something that is not divisible by 2. This can be used to pull squares out of the square root.



documentclass[tikz,border=1mm]standalone 
usepackagetikz-3dplot
usetikzlibraryfpu
newcounterifactor
newcommandPgfmathsetmacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathsetmacro#1#2%
pgfmathsmuggle#1endgroup
newcommandPgfmathtruncatemacroFPU[2]begingroup%
pgfkeys/pgf/fpu,/pgf/fpu/output format=fixed%
pgfmathtruncatemacro#1round(#2)%
pgfmathsmuggle#1endgroup
% the following functions are based on
% * https://tex.stackexchange.com/a/177109 (digitcount,digitsum,lastdigit)
% * https://tex.stackexchange.com/a/501895 (memberQ)
% or new in the sense that they were developed on the basis of the existing
% pgf functions
makeatletter
newcountc@Digits
newcountc@Powers
pgfmathdeclarefunctiondigitcount1%
begingroup%
globalc@Digits=0
expandafterDigitCount@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defGroupDigits#1%
% globalc@Digits=0
% expandafterDigitCount@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitCount@i#1#2@nil%
advancec@Digits by @ne
ifxrelax#2relaxelseDigitCount@i#2@nilfi

pgfmathdeclarefunctiondigitsum1%
begingroup%
globalc@Digits=0
expandafterDigitSum@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defDigitSum#1%
% globalc@Digits=0
% expandafterDigitSum@i#1@nil%
% pgfmathparseint(thec@Digits)
defDigitSum@i#1#2@nil%
advancec@Digits by #1
ifxrelax#2relaxelseDigitSum@i#2@nilfi

pgfmathdeclarefunctionlastdigit1%
begingroup%
globalc@Digits=0
expandafterLastDigit@i#1@nil%
pgfmathparseint(thec@Digits)%
pgfmathsmugglepgfmathresultendgroup
% defLastDigit#1%
% globalc@Digits=0
% expandafterLastDigit@i#1@nil%
% pgfmathparseint(thec@Digits)
defLastDigit@i#1#2@nil%
c@Digits=#1
ifxrelax#2relaxelseLastDigit@i#2@nilfi

pgfmathdeclarefunctionintegerpower2%
begingroup%
globalc@Powers=0%
pgfmathtruncatemacropgfutil@tmpa#1%
looppgfmathtruncatemacroitestgcd(pgfutil@tmpa,#2)%0
ifnumitest>1relax%
advancec@Powers by @ne%
pgfmathtruncatemacropgfutil@tmpapgfutil@tmpa/#2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower21% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacropgfutil@tmpblastdigit(pgfutil@tmpa)%
pgfmathtruncatemacroitestiseven(pgfutil@tmpb)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/2%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionintegerpower31% works with large numbers
begingroup%
pgfkeys/pgf/fpu=false%
globalc@Powers=0%
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
loop%
pgfmathtruncatemacroitestdivby3(pgfutil@tmpa)%
ifnumitest=1%
advancec@Powers by @ne%
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa/3%
repeat%
pgfmathparseint(thec@Powers)%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionmemberQ2%
begingroup%
edefpgfutil@tmpb0%
edefpgfutil@tmpa#2%
expandafterpgfmath@member@ipgfutil@firstofone#1pgfmath@token@stop
edefpgfmathresultpgfutil@tmpb%
pgfmath@smuggleonepgfmathresult%
endgroup
defpgfmath@member@i#1%
ifxpgfmath@token@stop#1%
else
ifnum#1=pgfutil@tmparelax%
gdefpgfutil@tmpb1%
fi%
expandafterpgfmath@member@i
fi
pgfmathdeclarefunctionisevenFPU1%
begingroup%
pgfmathparseiseven(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionisoddFPU1%
begingroup%
pgfmathparseisodd(lastdigit(#1))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiondivby31%
begingroup%
pgfmathparsememberQ(3,6,9,digitsum(digitsum(#1)))%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctiongcdFPU2%
begingroup
pgfkeys/pgf/fpu=false%
pgfmathcontinuelooptrue
PgfmathtruncatemacroFPUpgfutil@tmpa#1%
PgfmathtruncatemacroFPUpgfutil@tmpb#2%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpb%
fi%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpb==0,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpa%
fi%
PgfmathtruncatemacroFPUpgfutil@tmpaabs(pgfutil@tmpa)%
PgfmathtruncatemacroFPUpgfutil@tmpbabs(pgfutil@tmpb)%
loop
ifpgfmathcontinueloop%
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa==pgfutil@tmpb,1,0)%
ifnumitest=1relax
pgfmathcontinueloopfalse
else
PgfmathtruncatemacroFPUitestifthenelse(pgfutil@tmpa>pgfutil@tmpb,1,0)%
ifnumitest=1relax
PgfmathtruncatemacroFPUpgfutil@tmpapgfutil@tmpa-pgfutil@tmpb%
else
PgfmathtruncatemacroFPUpgfutil@tmpbpgfutil@tmpb-pgfutil@tmpa%
fi
fi
repeat
PgfmathtruncatemacroFPUpgfmathresultpgfutil@tmpa%
pgfmathsmugglepgfmathresultendgroup
pgfmathdeclarefunctionfactorinteger1%
begingroup% not yet done
endgroup

makeatother

newcommandPgfmathfraction[3]begingroup%
pgfmathtruncatemacromynumerator#2/gcd(#2,#3)%
pgfmathtruncatemacromydenominator#3/gcd(#2,#3)%
pgfmathsmuggle#1endgroup
begindocument
tdplotsetmaincoords7080
foreach a/b/c in 3/4/5,6/7/8,5/7/8
begintikzpicture[tdplot_main_coords,line join = round, line cap = round,
declare function=numerator(a,b,c)=pow(a,2) *pow(b,2)* pow(c,2);
denominator(a,b,c)=-pow(a,4) - pow(b,4) - pow(c,4)+%
2*pow(a,2) *pow(b,2)+2*pow(c,2) *pow(b,2)+2*pow(c,2)*pow(a,2);]
beginscope[local bounding box=elli]
PgfmathtruncatemacroFPUmynumeratornumerator(a,b,c)
PgfmathtruncatemacroFPUmydenominatordenominator(a,b,c)
PgfmathtruncatemacroFPUmygcdgcdFPU(mynumerator,mydenominator)
messagenumerator=mynumerator,denominator=mydenominator,gcd=mygcd^^J
PgfmathtruncatemacroFPUnewnumeratormynumerator/mygcd
PgfmathtruncatemacroFPUnewdenominatormydenominator/mygcd
messagenew numerator=newnumerator,new denominator=newdenominator^^J
pgfmathtruncatemacromyprenum1
pgfmathtruncatemacromypreden1
foreach Prime in 2,3,5,7,11,13,17
pgfmathtruncatemacromyintintegerpower(newnumerator,Prime)
ifnummyint>1
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewnumeratornewnumerator/pow(Prime,myint)
xdefnewnumeratornewnumerator
pgfmathtruncatemacromyprenummyprenum*pow(Prime,myint/2)
xdefmyprenummyprenum
fi
pgfmathtruncatemacromyintintegerpower(newdenominator,Prime)
ifnummyint>0
pgfmathtruncatemacromyint2*int(myint/2)
PgfmathtruncatemacroFPUnewdenominatornewdenominator/pow(Prime,myint)
xdefnewdenominatornewdenominator
pgfmathtruncatemacromypredenmypreden*pow(Prime,myint/2)
xdefmypredenmypreden
fi

messagenew numerator=newnumerator, pre num=myprenum,new
denominator=newdenominator, pre den=mypreden^^J
pgfmathsetmacromyr(myprenum/mypreden)*sqrt(newnumerator/newdenominator)
coordinate (A) at (0,0,0);
coordinate (B) at (c,0,0);
coordinate (C) at ((pow(b,2) + pow(c,2) - pow(a,2))/(2*c),sqrt((a+b-c) *(a-b+c) *(-a+b+c)* (a+b+c))/(2*c),0);
coordinate (T) at (c/2, c* (a*a + b*b - c*c)/(2*sqrt((a+b-c) *(a-b+c)* (-a+b+c)* (a+b+c))),0);
foreach point/position in A/left,B/below,C/right,T/below

fill (point) circle (1.8pt);
node[position=3pt] at (point) $point$;

beginscope[canvas is xy plane at z=0]
draw[thick] (T) circle (myr);
endscope
draw (T) -- (C) node[midway,sloped,fill=white] %
$displaystyleifnummypreden=1
myprenum
else
fracmyprenummypreden
fi
ifnumnewdenominator=1
ifnumnewnumerator=1
else
cdotsqrtnewnumerator
fi
else
ifnumnewnumerator=1
cdotfrac1sqrtnewdenominator
else
cdotsqrtfracnewnumeratornewdenominator
fi
fi,$cm;
endscope
node[above] at (elli.north)$a=a,b=b,c=c$;
endtikzpicture
enddocument


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 16 at 14:55

























answered Aug 16 at 5:49









Schrödinger's catSchrödinger's cat

3,0515 silver badges13 bronze badges




3,0515 silver badges13 bronze badges















  • I think, your answer is not automatically.

    – minhthien_2016
    Aug 16 at 5:58











  • Dunmo. I voted for your answer. But, your code doesn't true in every cases. E.G, triangle with lenght 6, 7, 8.

    – minhthien_2016
    Aug 16 at 10:34











  • Please try with sides 3, 4, 5. It is incorrect.

    – minhthien_2016
    Aug 16 at 10:36












  • Thank you very much.

    – minhthien_2016
    Aug 16 at 23:05






  • 1





    You can see package xintexpr.

    – minhthien_2016
    Aug 17 at 4:25

















  • I think, your answer is not automatically.

    – minhthien_2016
    Aug 16 at 5:58











  • Dunmo. I voted for your answer. But, your code doesn't true in every cases. E.G, triangle with lenght 6, 7, 8.

    – minhthien_2016
    Aug 16 at 10:34











  • Please try with sides 3, 4, 5. It is incorrect.

    – minhthien_2016
    Aug 16 at 10:36












  • Thank you very much.

    – minhthien_2016
    Aug 16 at 23:05






  • 1





    You can see package xintexpr.

    – minhthien_2016
    Aug 17 at 4:25
















I think, your answer is not automatically.

– minhthien_2016
Aug 16 at 5:58





I think, your answer is not automatically.

– minhthien_2016
Aug 16 at 5:58













Dunmo. I voted for your answer. But, your code doesn't true in every cases. E.G, triangle with lenght 6, 7, 8.

– minhthien_2016
Aug 16 at 10:34





Dunmo. I voted for your answer. But, your code doesn't true in every cases. E.G, triangle with lenght 6, 7, 8.

– minhthien_2016
Aug 16 at 10:34













Please try with sides 3, 4, 5. It is incorrect.

– minhthien_2016
Aug 16 at 10:36






Please try with sides 3, 4, 5. It is incorrect.

– minhthien_2016
Aug 16 at 10:36














Thank you very much.

– minhthien_2016
Aug 16 at 23:05





Thank you very much.

– minhthien_2016
Aug 16 at 23:05




1




1





You can see package xintexpr.

– minhthien_2016
Aug 17 at 4:25





You can see package xintexpr.

– minhthien_2016
Aug 17 at 4:25

















draft saved

draft discarded
















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f504392%2fhow-can-i-show-radius-of-this-circle-exactly%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?