Math & SciencePolynom division

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

Polynom division

Post by michael_b »

Hey everybody,

i have to tex a polynom division with the variable lambda. The polynom division looks like that:

\lambda^3-1 : (\lambda -1)

The result has to be \lambda^2+\lambda+1

And it has to show the different step of calculation.

Therefore i have taken the "polynom" package. However, there is a problem if i tex like that:

Code: Select all

[\polylongdiv[style=C,div=:,vars=\lambda]{\lambda^3-1}{\lambda-1}\]
Can anybody help.

Thanks a lot

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Polynom division

Post by gmedina »

Hi,

yes, I can reproduce the problem mentioned. The following example shows that the problem comes from the use of \lambda for the vars keys:

Code: Select all

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{polynom}

\begin{document}

% it won't work
%\[\polylongdiv[vars=\lambda,style=C,div=:]{\lambda^3-1}{\lambda-1}\]

% works OK
\[\polylongdiv[vars=l,style=C,div=:]{l^3-1}{l-1}\]

\end{document}
You should send a bug report to the package author.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Polynom division

Post by frabjous »

Hopefully someone else will know how to do this. I couldn't get it to work either, using Greek letters with TeX commands along with vars=...

I did, however, get this to work, compiling with XeLaTeX (using a unicode-compliant editor):

Code: Select all

\documentclass{article}
\usepackage{mathspec}
\defaultfontfeatures{Mapping=tex-text}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{polynom}
\setallmainfonts{Linux Libertine O}
\begin{document}
\[\polylongdiv[style=C,div=:,vars=λ]{λ^3-1}{λ-1}\]
\end{document}
(Replace "Linux Libertine O" with the name of some font on your system that has Greek letters in it.)

Might be a temporary workaround.
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

Re: Polynom division

Post by michael_b »

Yes it's really weird that it works with "l" or another character until we use a symbol which starts with an "\" e.g. "\lambda"

The unicode for lambda didn't work because i compiled with the programm WinEdit and if i take the lambda unicode to the tex-area the programme wouldn't recognize it, but writes a "?" instead.

gmedina thank you for the idea with the bug report.

But what can i do to solve this problem? or is there another way to get the result I want?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Polynom division

Post by localghost »

michael_b wrote:[...] But what can i do to solve this problem? [...]
At the moment nothing. Wait for the answer of the package maintainer. Feel free to post a summary of his message here.


Best regards
Thorsten
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Polynom division

Post by frabjous »

Contacting the package maintainer is definitely the way to go here, but still, if you need something in the short term, it might be worth installing TeXworks so you can use unicode. (You can switch back to WinEdt when the problem is fixed, or for that matter, just export cropped .pdfs of just the polynomial divisions you need and then include them in your document using \includegraphics or whatever.)
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

Re: Polynom division

Post by michael_b »

Thank you for your answers.

I have written the bug report to the maintainer. If i get an answer i will post it into this subject.
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

Polynom division

Post by michael_b »

Hey everybody!

I have contacted the "former" maintainer and he has given me the solution.

We can fix the problem in the preamble. Between "\makeatletter" and "/makeatother" you have to put this code:

Code: Select all

 
\define@key{pld}{vars}{% 
   \let\pld@variables\@empty 
   \@tfor\pld@temp:=#1\do{% 
     \pld@Extend\pld@variables{\expandafter,\pld@temp}% 
     \edef\pld@temp{% 
       \noexpand\define@key{pld}{\expandafter\string\pld@temp}% 
       {\noexpand\pld@GetValue{\expandafter\string\pld@temp}{####1}}% 
     }% 
     \pld@temp 
   }% 
} 


If you want to see a full test code you can watch it there:

Code: Select all

 
\documentclass{article} 
\usepackage{polynom} 
\makeatletter 
\define@key{pld}{vars}{% 
   \let\pld@variables\@empty 
   \@tfor\pld@temp:=#1\do{% 
     \pld@Extend\pld@variables{\expandafter,\pld@temp}% 
     \edef\pld@temp{% 
       \noexpand\define@key{pld}{\expandafter\string\pld@temp}% 
       {\noexpand\pld@GetValue{\expandafter\string\pld@temp}{####1}}% 
     }% 
     \pld@temp 
   }% 
} 
\makeatother 

\begin{document} 

\[\polylongdiv[style=C,div=:,vars=\lambda]{\lambda^3-1}{\lambda-1}\] 

\end{document} 
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Polynom division

Post by localghost »

Thank you for your effort. And did the maintainer say if we can expect a new release of the package or is maintenance discontinued?
michael_b
Posts: 15
Joined: Fri Nov 06, 2009 11:20 am

Re: Polynom division

Post by michael_b »

No Problem. The former maintainer has given me no information about that.
Post Reply