Professional Web Applications Themes

Equation - PHP Development

Hello people =) Has somebody a nice script, which can solve equations ? It would be super, if someone has an idea where I can get such a script / code in php. Thanks. Gretting!...

  1. #1

    Default Equation

    Hello people =)

    Has somebody a nice script, which can solve equations ?
    It would be super, if someone has an idea where I can get such a script /
    code in php.

    Thanks.

    Gretting!


    Sven Dzepina Guest

  2. #2

    Default Re: Equation

    Sven Dzepina wrote:
    >Hello people =)
    >
    >Has somebody a nice script, which can solve equations ?
    yes, I do now :-)
    >It would be super, if someone has an idea where I can get such a script /
    >code in php.
    Use mine
    >Thanks.
    you're welcome :-)))




    <?php // solve equation
    function solve($eq) {
    $eq = str_replace(' ', '', $eq);

    // validate expression
    $terms = explode('=', $eq);
    if (count($terms) != 2) {
    return('syntax error: you must have one (and only one) "=" in ['
    . $eq . '].');
    }

    // put rhs in lhs
    $eq = $terms[0] . '-(' . $terms[1] . ')';

    if (substr_count($eq, '(') != substr_count($eq, ')')) {
    return('syntax error: parenthesis mismatch in [' . $eq . '].');
    }
    if (preg_match('/\([^)]*\(/', $eq)) {
    return('syntax error: only one level of parenthesis allowed in ['
    . $eq . '].');
    }
    if (preg_match('/[^x0-9+*\/().=-]/', $eq)) {
    return('syntax error: the only valid characters are x, 0-9, +, '
    . '*, /, (, ), ., and - in [' . $eq . ']');
    }
    if (preg_match('/[^x0-9\)][-+\/*]/', $eq)) {
    return('syntax error: you can only operate on numbers in ['
    . $eq . ']');
    }
    if (preg_match('/[-+\/*][^x0-9\(]/', $eq)) {
    return('syntax error: you can only operate on numbers in ['
    . $eq . ']');
    }

    $eq = str_replace('x', '$x', $eq);
    $y0 = $y1 = 0;
    $x = 0; eval('$y0 = ' . $eq . ';');
    $x = 1; eval('$y1 = ' . $eq . ';');
    $slope = $y1 - $y0;
    $intersect = $y0;
    return (- ($intersect / $slope));
    }

    $eq = '2 * (x + 4) = 10';
    echo $eq, ' ==> x = ', solve($eq), '<br />';

    $eq = '(2 * x) + 4 = 10';
    echo $eq, ' ==> x = ', solve($eq), '<br />';

    $eq = '2 * x + 4 = 10';
    echo $eq, ' ==> x = ', solve($eq), '<br />';

    $eq = '4 + x / 10 = 2';
    echo $eq, ' ==> x = ', solve($eq), '<br />';
    ?>


    --
    I have a spam filter working.
    To mail me include "urkxvq" (with or without the quotes)
    in the subject line, or your mail will be ruthlessly discarded.
    Pedro Guest

  3. #3

    Default Re: Equation

    Big Thanks Pedro!
    It's a great script =)

    An Equation Script which can handle more variables would be better ;)


    "Pedro" <hexkidhotpop.com> schrieb im Newsbeitrag
    news:d2foov8ts7hjs4as316ki91ts6erme065m4ax.com...
    > Sven Dzepina wrote:
    > >Hello people =)
    > >
    > >Has somebody a nice script, which can solve equations ?
    >
    > yes, I do now :-)
    >
    > >It would be super, if someone has an idea where I can get such a script /
    > >code in php.
    >
    > Use mine
    >
    > >Thanks.
    >
    > you're welcome :-)))
    >
    >
    >
    >
    > <?php // solve equation
    > function solve($eq) {
    > $eq = str_replace(' ', '', $eq);
    >
    > // validate expression
    > $terms = explode('=', $eq);
    > if (count($terms) != 2) {
    > return('syntax error: you must have one (and only one) "=" in ['
    > . $eq . '].');
    > }
    >
    > // put rhs in lhs
    > $eq = $terms[0] . '-(' . $terms[1] . ')';
    >
    > if (substr_count($eq, '(') != substr_count($eq, ')')) {
    > return('syntax error: parenthesis mismatch in [' . $eq . '].');
    > }
    > if (preg_match('/\([^)]*\(/', $eq)) {
    > return('syntax error: only one level of parenthesis allowed in ['
    > . $eq . '].');
    > }
    > if (preg_match('/[^x0-9+*\/().=-]/', $eq)) {
    > return('syntax error: the only valid characters are x, 0-9, +, '
    > . '*, /, (, ), ., and - in [' . $eq . ']');
    > }
    > if (preg_match('/[^x0-9\)][-+\/*]/', $eq)) {
    > return('syntax error: you can only operate on numbers in ['
    > . $eq . ']');
    > }
    > if (preg_match('/[-+\/*][^x0-9\(]/', $eq)) {
    > return('syntax error: you can only operate on numbers in ['
    > . $eq . ']');
    > }
    >
    > $eq = str_replace('x', '$x', $eq);
    > $y0 = $y1 = 0;
    > $x = 0; eval('$y0 = ' . $eq . ';');
    > $x = 1; eval('$y1 = ' . $eq . ';');
    > $slope = $y1 - $y0;
    > $intersect = $y0;
    > return (- ($intersect / $slope));
    > }
    >
    > $eq = '2 * (x + 4) = 10';
    > echo $eq, ' ==> x = ', solve($eq), '<br />';
    >
    > $eq = '(2 * x) + 4 = 10';
    > echo $eq, ' ==> x = ', solve($eq), '<br />';
    >
    > $eq = '2 * x + 4 = 10';
    > echo $eq, ' ==> x = ', solve($eq), '<br />';
    >
    > $eq = '4 + x / 10 = 2';
    > echo $eq, ' ==> x = ', solve($eq), '<br />';
    > ?>
    >
    >
    > --
    > I have a spam filter working.
    > To mail me include "urkxvq" (with or without the quotes)
    > in the subject line, or your mail will be ruthlessly discarded.

    Sven Dzepina Guest

  4. #4

    Default Re: Equation

    Sven Dzepina wrote:
    > Big Thanks Pedro!
    > It's a great script =)
    LOL, thanks

    > An Equation Script which can handle more variables would be better ;)
    Yes, I'm pretty sure it would.
    If you can guarantee the equations are normalized

    3x - 6 = 0

    instead of

    4(x-1) = x+2

    that makes making the solver script terribly easy for

    a) ax+b=0
    b) ax^2+bx+c=0
    c) ax+by+c=0 (and) dx+ey+f=0
    d) ...

    Input only the constants ... not the whole equation;
    for the equation above you'd input only: a=3, and b=-6

    and then solve (after checking for division by zero only):
    return -($b/$a);


    or, for equation in type 2:
    return array((-$b+sqrt($a*$a-4*$a*$c))/(2*$a),
    (-$b-sqrt($a*$a-4*$a*$c))/(2*$a));

    etc. ... ...



    Happy Coding :-)

    Pedro Guest

  5. #5

    Default Re: Equation

    Hi Pedro,

    you must be a very intelligent human =)

    Gretting.

    "Pedro" <hexkidhotpop.com> schrieb im Newsbeitrag
    news:bmhvt2$n6tdt$1ID-203069.news.uni-berlin.de...
    > Sven Dzepina wrote:
    > > Big Thanks Pedro!
    > > It's a great script =)
    >
    > LOL, thanks
    >
    >
    > > An Equation Script which can handle more variables would be better ;)
    >
    > Yes, I'm pretty sure it would.
    > If you can guarantee the equations are normalized
    >
    > 3x - 6 = 0
    >
    > instead of
    >
    > 4(x-1) = x+2
    >
    > that makes making the solver script terribly easy for
    >
    > a) ax+b=0
    > b) ax^2+bx+c=0
    > c) ax+by+c=0 (and) dx+ey+f=0
    > d) ...
    >
    > Input only the constants ... not the whole equation;
    > for the equation above you'd input only: a=3, and b=-6
    >
    > and then solve (after checking for division by zero only):
    > return -($b/$a);
    >
    >
    > or, for equation in type 2:
    > return array((-$b+sqrt($a*$a-4*$a*$c))/(2*$a),
    > (-$b-sqrt($a*$a-4*$a*$c))/(2*$a));
    >
    > etc. ... ...
    >
    >
    >
    > Happy Coding :-)
    >

    Sven Dzepina Guest

  6. #6

    Default equation

    Hi,

    First of all, I'm sorry for my English.
    My native language not english.

    I have got some Word(.doc) doents. Including a lot of equations.
    (every page 8-10 equation, 300 page, this is engineering book)
    I'm import this in InDesign. If equation is single line Ok. But two line equations problem. When I'm export this eq's not show correctly.

    If you want see.
    <http://www.atlasgold.net/4adobe/test_4_forum1.gif>
    <http://www.atlasgold.net/4adobe/test_4_forum1.pdf>
    <http://www.atlasgold.net/4adobe/test_1.indd>

    I don't solve this. Anyone Solution?

    thanks.

    I use InDesign Cs CE(central europe edition).
    Windows XP+sp1
    Microsoft Word XP.
    Athlon 2500+, 512 DDR ram.
    tuncer@adobeforums.com Guest

  7. #7

    Default Re: equation


    If you are using Word Equations, you should get Mathtype (Word Equations
    big brother). Use Mathtype to resave the equations as external eps files
    and re-import via linked files rather than embedded equations.

    Mike
    MikeKazlow@adobeforums.com Guest

  8. #8

    Default Re: equation

    Please think.

    8 equation x 300 page= 2400 equation !!!

    We wrote in Ms.Word.
    Again write this? 2400 equation :-(
    It's horrible.
    tuncer@adobeforums.com Guest

  9. #9

    Default Re: equation

    > We wrote in Ms.Word.
    > Again write this? 2400 equation :-(
    > It's horrible.
    Equation Editor does not work with InDesign. Sorry!

    -John O



    JohnO@adobeforums.com Guest

  10. #10

    Default Re: equation

    Have you tried saving the word doent as a pdf and then placing the pdf? This should keep the text from reflowing.
    ms_barr@adobeforums.com Guest

  11. #11

    Default Re: equation

    I do the layout of a scientific magazine. I get articles in from other people, and some of them contain many equations. I am new to InDesign and do not know how to import these equations in InDesign. When I just "place" the file, the equations are there but they don't look good - look like very low-resolution images. Can anyone help? My e-mail address is [email]drinievwrc.org.za[/email] and I would appreciate any help.
    Drinie_van_Rensburg@adobeforums.com Guest

  12. #12

    Default Re: equation

    Go to View => Display Performance => High Quality Display [Ctrl+Alt+H]

    A good program for equations is MathType ([url]http://www.dessci.com/en/[/url]).
    With MathType you can export your equations to eps-format and import them
    into Indesgn (or just copy-paste).



    <Drinie_van_Rensburgadobeforums.com> wrote in message
    news:3bb54bf5.4webx.la2eafNXanI...
    >I do the layout of a scientific magazine. I get articles in from other
    >people, and some of them contain many equations. I am new to InDesign and
    >do not know how to import these equations in InDesign. When I just "place"
    >the file, the equations are there but they don't look good - look like very
    >low-resolution images. Can anyone help? My e-mail address is
    >drinievwrc.org.za and I would appreciate any help.

    Pietje Bell Guest

  13. #13

    Default Re: equation

    Drinie,

    What format are your articles submitted in? Are the equations embedded
    in the doents or referefenced. This forum works by users posting
    questions and other answering in the forum directly.

    Mike
    MikeKazlow@adobeforums.com Guest

  14. #14

    Default Re: equation

    The articles are submitted in Word. Sometimes they are embedded, sometimes not. I wish I could send someone an example of the type of files I'm working with. At this stage I use Pagemaker 7.0 which works OK with equations but I have problems exporting the files to PDF.
    Drinie_van_Rensburg@adobeforums.com Guest

  15. #15

    Default Re: equation

    Unfortunately you will need to export your equations as EPS/TIFF files and then import them into your Pagemaker 7.0 files, especially if you're working on Windows. The problem with placing Word files with equations (either from Equation Editor or MathType) is that they become metafiles which cause problems when creating PDF. Right now I'm wondering how to convert Pagemaker 7.0 files that have the EPS/TIFF images placed in them, to InDesign CS 3 Pagemaker Edition without having to import all over again, or manually move each equation that now sits on the BASELINE instead of centering vertically! Has anyone else had this problem and come up with a solution?
    Linda_Marie_Williams@adobeforums.com Guest

  16. #16

    Default Re: equation

    Found a great script written by Dave Saunders on this site at Dave Saunders "Inline Equations X InDesign CS" 5/28/04 8:07am </cgi-bin/webx?14.3bb45239/7> that centers the equations vertically on the line based on the height of the equation! Fantastic! Thanks, Dave!
    Linda_Marie_Williams@adobeforums.com Guest

Similar Threads

  1. Equation Editor in Indesign
    By Availor_Black_Bird@adobeforums.com in forum Adobe Indesign Windows
    Replies: 9
    Last Post: August 17th, 05:03 PM
  2. Chart a regression equation
    By jmicah in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: August 9th, 05:29 PM
  3. equation signs
    By enhm in forum Macromedia Freehand
    Replies: 0
    Last Post: April 19th, 04:22 PM
  4. Drawing Quadratic Equation with ActionScript
    By Peder Jakobsen in forum Macromedia Flash
    Replies: 1
    Last Post: February 12th, 06:49 AM
  5. 3d transform object equation???
    By ressurect webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 1
    Last Post: September 22nd, 01:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139