I am trying to program series equation in Perl and solve for the 'x' at the end.
my equation is
$c = 1 or 0; - different value(0 or 1) for each for loop
$q is given value - different value each for loop though
for ($i=1; $i<1000; i++) { $sum_equ ={(1-$c[$i])(1-2*$q[$i])}/(-2*$q[$i]*$x +$x +$q[$i]) + +{$c[$i]*(2*$q[$i] -1)}/(2*$q[$i]*$x-$x+1) }
$c values determines which part of valued to be added.
I am hoping '$sum_equ' contains sum of all equations and set the final equations as zero, then solve for the $x value at the end.
for example...
I have 1000 iterations to to be begin with $sum_equ = 0;
when i=0; $sum_equ = (1 - 2*10)/(-2*10*$x +$x +10); when i=1; $sum_equ = (1 - 2*10)/(-2*10*$x +$x +10) +(2*5 -1)/(2* +5*$x-$x+1); ..... when i=999; $sum_equ = (1 - 2*10)/(-2*10*$x +$x +10) +(2*5 -1)/( +2*5*$x-$x+1)+ ....... + (2*22 -1)/(2*22*$x-$x+1);
then $sum_equ = 0
Solve for $x value
pseudo code would be... I am stuck at what functions to use or how to implement it...
for ($i=1;$i<1000;$i++) { if ($c==1) { $sum_equ = $sum_equ + (1 - 2*$q[$i]/(-2*$q[$i] +*$x +$x +$q[$i] ); } elsif ($c ==0) { $sum_equ = $sum_equ + (2*$q[$i] -1)/(2*$q[$i]* +$x-$x+1); } # End of if } #end of for
I would greatly appreciate any comments or opinion.
Thank you so much.
2018-03-22 Athanasius Added code tags and removed paragraph tags from within code
In reply to Solve for 'x' in series by sbae
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |