<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br><div>I'm new at GiNaC and I use the lib for create a gradient descent algorithm (symbolic calculating).</div></div><div>I have a formula "a*x^3+b*y^4" and I subsitute the formula in the error function "0.5*(t - <formula>)^2".</div><div>After the substitution GiNaC returns the expression "(0.5)*(a*x^3+b*y^4-t)^2".</div><div><br></div><div>I use this code:</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #3f6e74">GiNaC</span>::<span style="color: #3f6e74">ex</span> m_expression;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; color: rgb(0, 116, 0); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><span style="color: #3f6e74">GiNaC</span>::<span style="color: #3f6e74">symtab</span> m_exprtable;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; color: rgb(0, 116, 0); "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;"><font class="Apple-style-span" color="#3F6E74" face="Monaco"><br></font></span></font></div></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><font class="Apple-style-span" color="#3F6E74"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #aa0d91">try</span> {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>m_expression = <span style="color: #3f6e74">l_parser</span>( "<span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; ">a*x^3+b*y^4</span>" );</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "> m_exprtable = <span style="color: #3f6e74">l_parser</span>.get_syms();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; ">} <span style="color: #aa0d91">catch</span> (...) {}</div><div><br></div></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #3f6e74"><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #3f6e74">GiNaC</span>::ex <span style="color: #3f6e74">l_full</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #3f6e74">GiNaC</span>::symtab <span style="color: #3f6e74">l_table</span>(m_exprtable);</div></div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #3f6e74">l_table</span>["formula"] = m_expression;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #3f6e74">GiNaC</span>::parser <span style="color: #3f6e74">l_parser</span>(<span style="color: #3f6e74">l_table</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; min-height: 16px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #aa0d91">try</span> {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; "><span style="color: #3f6e74"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span>l_full</span> = <span style="color: #3f6e74">l_parser</span>( "<span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; ">0.5*(t - formula)^2"</span> ); // (*)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Monaco; ">} <span style="color: #aa0d91">catch</span> (...) {}</div></div><div><br></div><div>std::cout << l_full << std::endl;</div><div><br></div><div><br></div><div>I using the version 1.5.8 (on 1.5.7 I had got a compiler error). </div><div><br></div><div>Is this the correct way for concating two symbolic expression?</div><div>Do I have forgot anything?</div><div><br></div><div>Thanks</div><div><br></div><div>Phil</div><div><br></div></body></html>